学习记录
开发流程:
1.创建实体类-->2.创建Spring Bean Configuration File 文件,并配置-->3.测试类调用
1.创建实体类:
[*]public class People {
[*] private int id;
[*] private String name;
[*] private int age;
[*] //Setter/Getter方法(必须有)
[*] //无参构造器(必须有)
[*] //toString()
[*]}
2.创建Spring Bean Configuration File 文件,并配置
[*]<bean id="对象名(people)" class="类名(com.lhs.dto.People)">
[*] <property name="属性名(name)" value="属性值("张三")"></property>
[*] <property name="属性名(age)" value="属性值(23)"></property>
[*]</bean>
3.测试类调用
[*]//加载xml 配置文件
[*]ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationConfig.xml");
[*]//创建实例
[*]People people = (People) applicationContext.getBean("people");
[*]System.out.println(people);
谢谢楼主的分享!。。。 谢谢楼主
页:
[1]