日期:2014-05-18  浏览次数:21005 次

spring配置问题:'target' is required
为什么报这个错呢? 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDAOProxy ' defined in ServletContext resource [/WEB-INF/applicationContext-transa.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: 'target ' is required 

java.lang.IllegalArgumentException: 'target ' is required 

我的配置文件内容如下 

<bean id="userDAOProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" > 
   
  <property name="transactionManager" > 
  <ref bean="myTransactionManager"/ > 
  </property > 
  <property name="transactionAttributes" >  
  <props > 
  <prop key="Add*" >PROPAGATION_REQUIRED </prop > 
  <prop key="Modi*" >PROPAGATION_REQUIRED </prop > 
  <prop key="Delete*" >PROPAGATION_REQUIRED </prop > 
  <prop key="Select*" >PROPAGATION_REQUIRED </prop > 
  </props > 
  </property > 
</bean > 

<bean name="/login" class="com.icss.scte.ssh.action.LoginAction" singleton="false" > 
  <property name="sel" > 
  <ref bean="userDAOProxy"/ > 
  </property > 
  <property name="add" > 
  <ref bean="userDAOProxy"/ > 
  </property > 
</bean > 

  <bean id="selectImpl" parent="userDAOProxy" > 
  <property name="target" > 
  <ref bean="selectImpl"/ > 
  </property > 
  </bean > 
  
  <bean name="selectImpl" class="com.icss.scte.ssh.daoimpl.SelectImpl" > 
  <property name="sessionFactory" > 
  <ref bean="sessionFactory"/ > 
  </property > 
  </bean > 

LoginAction中为: 

private Select sel; 
private Add add; 


public Select getSel() { 
return sel; 


public void setSel(Select sel) { 
this.sel = sel; 


public Add getAdd() { 
return add; 


public void setAdd(Add add) { 
this.add = add; 
}

------解决方案--------------------
<bean id="userDAOProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" > 

<property name="transactionManager" > 
<ref bean="myTransactionManager"/ > 
</property > 
<property name="target">
<ref local="selectImpl" />
</property>
<property name=