ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
### bean ~~~ public class UserService { private String name; private Integer age; private Date birthday; public void setName(String name) { this.name = name; } public void setAge(Integer age) { this.age = age; } public void setBirthday(Date birthday) { this.birthday = birthday; } public void saveUser(){ System.out.println(name + " --- "+ age + " --- "+ birthday); } } ~~~ ### bean.xml ~~~ <!--配置一个日期对象--> <bean id="now" class="java.util.Date"/> <bean name="userService" class="com.test.service.UserService"> <property name="name" value="test"/> <property name="age" value="11"/> <property name="birthday" ref="now"/> </bean> ~~~ ### test ~~~ public static void main(String[] args) { ApplicationContext ac = new ClassPathXmlApplicationContext("bean.xml"); UserService userService = (UserService) ac.getBean("userService"); userService.saveUser(); } ~~~