出现org.springframework.beans.factory.BeanCreationException这个错误,不知道怎么改了,大家帮帮忙
bean.xml文件的内容[b][/b] <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
</property>
<property name="url"
value="jdbc:sqlserver://localhost:1433;DatabaseName=HR_DB">
</property>
<property name="username" value="sa"></property>
<property name="password" value="12"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/myhr/entity/Bonus.hbm.xml</value>
<value>com/myhr/entity/ConfigFileFirstKind.hbm.xml</value>
<value>com/myhr/entity/ConfigFileSecondKind.hbm.xml</value>
<value>com/myhr/entity/ConfigFileThirdKind.hbm.xml</value>
<value>com/myhr/entity/ConfigMajor.hbm.xml</value>
<value>com/myhr/entity/ConfigMajorKind.hbm.xml</value>
<value>com/myhr/entity/ConfigPrimaryKey.hbm.xml</value>
<value>com/myhr/entity/ConfigPublicChar.hbm.xml</value>
<value>com/myhr/entity/ConfigQuestionFirstKind.hbm.xml</value>
<value>com/myhr/entity/ConfigQuestionSecondKind.hbm.xml</value>
<value>com/myhr/entity/EngageAnswer.hbm.xml</value>
<value>com/myhr/entity/EngageAnswerDetails.hbm.xml</value>
<value>com/myhr/entity/EngageExam.hbm.xml</value>
<value>com/myhr/entity/EngageExamDetails.hbm.xml</value>
<value>com/myhr/entity/EngageInterview.hbm.xml</value>
<value>com/myhr/entity/EngageMajorRelease.hbm.xml</value>
<value>com/myhr/entity/EngageResume.hbm.xml</value>
<value>com/myhr/entity/EngageSubjects.hbm.xml</value>
<value>com/myhr/entity/HumanFile.hbm.xml</value>
<value>com/myhr/entity/MajorChange.hbm.xml</value>
<value>com/myhr/entity/MenutreeInfo.hbm.xml</value>
<value>com/myhr/entity/SalaryGrant.hbm.xml</value>
<value>com/myhr/entity/SalaryStandard.hbm.xml</value>
<value>com/myhr/entity/SalaryStandardDetails.hbm.xml</value>
<value>com/myhr/entity/SysRole.hbm.xml</value>
<value>com/myhr/entity/SysRoleRight.hbm.xml</value>
<value>com/myhr/entity/SysUser.hbm.xml</value>
<value>com/myhr/entity/Sysdiagrams.hbm.xml</value>
<value>com/myhr/entity/Training.hbm.xml</value>
</list>
</property>
</bean>
bean-fanbo文件里面的内容[color=#FF0000][/color]<import resource="bean.xml"/>
<!-- testdao -->
<bean id="testdao" class="com.myhr.dao.impl.TestdaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- testbiz -->
<bean id="testbiz" class="com.myhr.biz.impl.TestbizImpl">
<property name="td" ref="testdao"></property>
</bean>
<!-- testAction -->
<bean name="/test" class="com.myhr.web.action.TestAction">
<property name="tb" ref="testbiz"></property>
</bean>
出错:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name '/test' defined in ServletContext resource [/WEB-INF/classes/fanbo.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'tb' of bean class [com.myhr.web.action.TestAction]: Bean property 'tb' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'tb' of bean class [com.myhr.web.action.TestAction]: Bean property 'tb' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:751)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:608)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValue(AbstractPropertyAccessor.java:49)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:74)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:57)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:970)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:729)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:416)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:141)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:156)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:290)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:348)
at org.springframework.web.context.support.AbstractRefreshableWebApplicationContext.refresh(AbstractRefreshableWebApplicationContext.java:156)
at org.springframework.web.struts.ContextLoaderPlugIn.createWebApplicationContext(ContextLoaderPlugIn.java:355)
at org.springframework.web.struts.ContextLoaderPlugIn.initWebApplicationContext(ContextLoaderPlugIn.java:296)
at org.springframework.web.struts.ContextLoaderPlugIn.init(ContextLoaderPlugIn.java:225)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServlet.java:839)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:332)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4042)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4348)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2011-12-12 22:54:58 org.apache.catalina.core.ApplicationContext log
[解决办法]
第一:看你的bean文件set、get方法给了没有
第二:最好能将bean的命名改一下。不要有“/”之类的出现