}
}
Spring配置文件
<?xml version="1.0" encoding="UTF-8"?><beans xmlns=“http://www.springframework.org/schema/beans”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xmlns:context=“http://www.springframework.org/schema/context”
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd ">
User.java
public class User{
private String name;
private Integer age;
//关于name,age的getter/setter方法省略
public User(String name,int age){
this.name = name;
this.age = age;
}
}
通过Spring配置文件来注入这User这个对象
<?xml