高手求救:Spring集成问题
spring配置文件
<beans>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@127.0.0.1:1521:ORCL">
</property>
<property name="username" value="fund"></property>
<property name="password" value="fund"></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.Oracle9Dialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>edu/xust/fund/orm/Proposerinfo.hbm.xml</value>
<value>edu/xust/fund/orm/Iteminfo.hbm.xml</value>
<value>edu/xust/fund/orm/Userinfo.hbm.xml</value>
<value>edu/xust/fund/orm/Bugdetoutlay.hbm.xml</value>
<value>edu/xust/fund/orm/College.hbm.xml</value>
<value>edu/xust/fund/orm/Distribute.hbm.xml</value>
<value>edu/xust/fund/orm/Sort.hbm.xml</value>
<value>edu/xust/fund/orm/Declaretime.hbm.xml</value>
<value>edu/xust/fund/orm/Experinfo.hbm.xml</value>
</list>
</property>
</bean>
<bean id="userinfoDao" class="edu.xust.fund.service.UserinfoDao">
<property name="dataSource">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean name="login" class="edu.xust.fund.action.LoginAction">
<property name="userinfoDao">
<ref bean="userinfoDao"/>
</property>
</bean>
</beans>
急……谢谢!
spring配置文件
<beans>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@127.0.0.1:1521:ORCL">
</property>
<property name="username" value="fund"></property>
<property name="password" value="fund"></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.Oracle9Dialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>edu/xust/fund/orm/Proposerinfo.hbm.xml</value>
<value>edu/xust/fund/orm/Iteminfo.hbm.xml</value>
<value>edu/xust/fund/orm/Userinfo.hbm.xml</value>
<value>edu/xust/fund/orm/Bugdetoutlay.hbm.xml</value>
<value>edu/xust/fund/orm/College.hbm.xml</value>
<value>edu/xust/fund/orm/Distribute.hbm.xml</value>
<value>edu/xust/fund/orm/Sort.hbm.xml</value>
<value>edu/xust/fund/orm/Declaretime.hbm.xml</value>
<value>edu/xust/fund/orm/Experinfo.hbm.xml</value>
</list>
</property>
</bean>
<bean id="userinfoDao" class="edu.xust.fund.service.UserinfoDao">
<property name="dataSource">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean name="login" class="edu.xust.fund.action.LoginAction">
<property name="userinfoDao">
<ref bean="userinfoDao"/>
</property>
</bean>
</beans>
急……谢谢!
解决方案 »
- toString() unavailable - no suspended threads
- 在一次会话(session)中,怎么判断某个页面是否被打开了?
- 菜菜菜鸟提问:eclipse打不开提示错误是怎么回事啊,急!!
- (404)Servlet AxisServlet is not available
- sprnig2.X关于AOP的问题
- java 异常问题
- 学习框架或者考SCWCD大家看什么书,推荐一下!
- 大家帮忙啊,一个最简单的Struts中的bean:write我搞不定了,,大家帮忙。
- 在另一台客户机上如何运行J2EE服务器中的程序ConverterEJB?
- 关于jsp在线求助
- 一 段 简 单 的 代 码 , 就 是 不 知 道 错 在 哪 。
- xsl里怎么判断xml里面某个节点的值为空?
严重: StandardWrapper.Throwable
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userinfoDao' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'dataSource' of bean class [edu.xust.fund.service.UserinfoDao]: Bean property 'dataSource' 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 'dataSource' of bean class [edu.xust.fund.service.UserinfoDao]: Bean property 'dataSource' 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:793)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:645)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1127)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:249)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:155)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:246)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:291)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:246)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:189)
at org.springframework.web.context.ContextLoaderServlet.init(ContextLoaderServlet.java:82)
at javax.servlet.GenericServlet.init(GenericServlet.java:212)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1172)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:992)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4371)
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:926)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
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:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
2009-5-10 10:10:20 org.apache.catalina.core.StandardContext loadOnStartup
dao中声明的dataSource的类型与注入的类型不一致了吧
应该很明显了
另外你注入的内容错误了
<bean id="userinfoDao" class="edu.xust.fund.service.UserinfoDao">
<property name="dataSource">
<ref bean="sessionFactory"/>
</property>
--------------------------------------------------------------------
改成
<bean id="userinfoDao" class="edu.xust.fund.service.UserinfoDao">
<property name="dataSource">
<ref bean="dataSource"/>
</property>
或者
<bean id="userinfoDao" class="edu.xust.fund.service.UserinfoDao">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
对应的get,set也需要改变
<plug-in
className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml" />
</plug-in>
现在不行了,得在web.xml中配置。
能不能告诉我这些都是什么原因造成的?谢谢!
<bean id="userinfoDao" class="edu.xust.fund.service.UserinfoDao">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>