当前位置: 代码迷 >> J2EE >> Spring2 +Hibernate3 配置时出现:“No setter found for property 'target'”!该怎么解决
  详细解决方案

Spring2 +Hibernate3 配置时出现:“No setter found for property 'target'”!该怎么解决

热度:71   发布时间:2016-04-22 01:58:48.0
Spring2 +Hibernate3 配置时出现:“No setter found for property 'target'”!
在Spring2 +Hibernate3 配置时出现:“No setter found for property 'target' in class 'org.springframework.transaction.interceptor.TransactionProxyFactoryBean'”的错误!

原代码如下:
applicationContext.xml里的代码:

<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<!-- classpath = src/ -->
  <value>classpath:hibernate.cfg.xml</value>
  </property>
</bean>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>

<bean id="userDAO" class="com.operation.daoimpl.UserDAOImpl">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>

<bean id="userManager" class="com.struts2.action.UserManagerAction">
<property name="userDAO">
<ref local="userDAO"/>
</property>
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
</bean>

<bean id="userManagerProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target"><!--这里出错-->
<ref local="userManager"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="find*">
PROPAGATION_SUPPORTS,readOnly
</prop>
</props>
</property>
</bean>

</beans>
请大家帮忙解决。
 

------解决方案--------------------
你相应的类中没有setter方法,Spring怎么进行依赖注入呢?
所以,问题不在applicationContext.xml,而在你的定义了
target属性的那个类中,请再那个类中添加相应的setter方法。
OK?
  相关解决方案