public class Role { private Log id; private String roleName; private String note; public Role(String roleName, String note) { this.roleName = roleName; this.note = note; } @Override public String toString() { return "Role{ " + "id=" + id + ", roleName='" + roleName + '\'' + ", note='" + note + '\'' + '}'; }}
xml:
测试代码:
public static void main(String[] args) { ApplicationContext A=new ClassPathXmlApplicationContext("spring/my-spring.xml"); Object role1 = A.getBean("role1"); //System.out.println(((Role)role1).toString()); System.out.println((Role)role1); }
结果: