Class A:
Packagetest;/*** Created by Gmq on 2015/12/4.*/ Public classa{PrivateString AA; PrivateLong BB; PrivateInteger cc; PublicInteger GETCC () {returncc; } Public voidSETCC (Integer cc) { This. CC =cc; } PublicString Getaa () {returnAA; } Public voidsetaa (String aa) { This. AA =AA; } PublicLong GETBB () {returnBB; } Public voidsetbb (Long bb) { This. BB =BB; }}
Class B:
Packagetest;/*** Created by Gmq on 2015/12/4.*/ Public classb{PrivateString AA; PrivateLong BB; PrivateString cc; PublicString Getaa () {returnAA; } Public voidsetaa (String aa) { This. AA =AA; } PublicLong GETBB () {returnBB; } Public voidsetbb (Long bb) { This. BB =BB; } PublicString GETCC () {returncc; } Public voidSETCC (String cc) { This. CC =cc; }}
Test class:
Packagetest;Importcom.banksteel.erp.dto.inventory.allot.InventoryItemDto;ImportCom.banksteel.erp.inventory.entity.inventory.InventoryItem;ImportCom.github.pagehelper.PageInfo;Importorg.springframework.beans.BeanUtils;Importjava.util.ArrayList;Importjava.util.List;/*** Created by Gmq on 2015/12/4.*/ Public classtestutil{ Public Static voidMain (String args[]) {A A=NewA (); A.setaa ("Test"); A.SETBB (11L); A.SETCC (2); b b=NewB (); Beanutils.copyproperties (A, b); System.out.println (A.getaa ()+ "+ A +" "+ A.GETBB () +", C: "+A.GETCC ()); System.out.println (B.getaa ()+ "+ B +" "+ B.GETBB () +", C: "+B.GETCC ());//Inventoryitem item = new Inventoryitem ();//Item.setstatus (one);//Item.setitemcode ("Gmq");////inventoryitemdto dto = new Inventoryitemdto ();//beanutils.copyproperties (item, DTO);//System.out.println (Item.getstatus () + "+" "+ Item.getitemcode ());//System.out.println (Dto.getstatus () + "+" "+ Dto.getitemcode ());//pageinfo<inventoryitemdto> dtopage = new pageinfo<> ();//pageinfo<inventoryitem> itempage = new pageinfo<> ();//list<inventoryitem> items = new arraylist<> ();//Inventoryitem item = new Inventoryitem ();//Item.setid (123L);//Items.Add (item);////itempage.setlist (items);//itempage.setlist (null);//itempage.setpagesize (+);//beanutils.copyproperties (Itempage, dtopage);//System.err.println (dtopage); }}
Above
Spring's object property is the same (type, name) copy