java Spring的配置问题

来源:百度知道 编辑:UC知道 时间:2024/06/07 23:00:36
我在Spring中注入日期但是报错这个是为什么那位能帮助解决下:
applicationContext.xml文件代码:
<beans>

<bean id="ss" class="com.my.po.Stu">
<property name="age">
<value type="int">12</value>
</property>
<property name="birth">
<value>2009-09-09</value>
</property>
<property name="name">
<value>langa</value>
</property>

</bean></beans>
TestStu.java文件代码:
ApplicationContext ss=new FileSystemXmlApplicationContext("src/applicationContext.xml");
Stu dd=(Stu)ss.getBean("dd");
System.out.println(dd.getBirth());
报下面的错误:Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ss' defined in file [F:\JAVA空间\MyEcleip空间\ssss\src\applicationC

类型不匹配,这两个:
<property name="birth">
<value>2009-09-09</value>
</property>
<property name="name">
<value>langa</value>
少了type

日期没有在配置文件中定义类型啊,所以生成bean时出错

Stu dd=(Stu)ss.getBean("dd"); 为什么getBean("dd");dd没见你注入过呀