首页 > 代码库 > 错误信息:Bean property 'sessionFactory' is not writable or has an invalid setter method.(Springmvc)

错误信息:Bean property 'sessionFactory' is not writable or has an invalid setter method.(Springmvc)

是在建立class的时候对应的set方法和spring配置文件的不一样

 

public class GoodsService implements IGoodsService{
private IGoodDAO goodsDao;

public void setGoodsDao(IGoodDAO goodsDao) {
this.goodsDao = goodsDao;
}

 

}

public class GoodDAO implements IGoodDAO{
private SessionFactory sessionFactory;

public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}

}

@Resource(name="goodsService")
private IGoodsService goodsService;

 

 

 

其中加黑的部分要对应起来,不然启动tomcat启动时就会出现这个错误的信息。

 

 

<!-- Goods类 -->
<bean id="goodsDao" class="cn.lion.dao.GoodDAO">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<!-- 代理事务 -->
<bean id="goodsServiceBase" class="cn.lion.service.GoodsService">
<property name="goodsDao" ref="goodsDao"></property>

</bean>
<bean id="goodsService" parent="transactionBese">
<property name="target" ref="goodsServiceBase"></property>
</bean>

错误信息:Bean property 'sessionFactory' is not writable or has an invalid setter method.(Springmvc)