日期:2014-05-20  浏览次数:20760 次

Spring集成问题
高手求救: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>




急……谢谢!

------解决方案--------------------
userinfoDao要有get,set方法
另外你注入的内容错误了
<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也需要改变