package test;

import java.util.Date;

import org.springframework.beans.BeanUtils;

import test.basic.BasicT;

public class BeanTest extends BasicT{
	public static void main(String[] args) {
		User user=new User();
		user.setUseId(12);
		user.setUserName("userName");
		user.setMyname("sawme");
		UU uu=new UU();
		BeanUtils.copyProperties(user, uu);
		System.out.println(uu.toString());

	}
}

	class User{
		private int useId;
		private String userName;
		private String myname;
		public int getUseId() {
			return useId;
		}
		public void setUseId(int useId) {
			this.useId = useId;
		}
		public String getUserName() {
			return userName;
		}
		public void setUserName(String userName) {
			this.userName = userName;
		}
		public String getMyname() {
			return myname;
		}
		public void setMyname(String myname) {
			this.myname = myname;
		}

	}
	class UU{
		private int useId;
		private Date userName;
		private String uname;
		public int getUseId() {
			return useId;
		}
		public void setUseId(int useId) {
			this.useId = useId;
		}
		public Date getUserName() {
			return userName;
		}
		public void setUserName(Date userName) {
			this.userName = userName;
		}
		public String getUname() {
			return uname;
		}
		public void setUname(String uname) {
			this.uname = uname;
		}
		@Override
		public String toString() {
			return "UU [useId=" + useId + ", userName=" + userName + ", uname=" + uname + "]";
		}

	}

  输出结果

UU [useId=12, userName=null, uname=null]

 类型不同不作转换,名称不同也不做转换 

05-02 01:14