大家帮我看看我那里配置错了
这是一个配置文件applicationContext-service-afford.xml
<beans>
<bean id= "feeManagerService " class= "com.bytime.toss.finance.charge.service.impl.FeeManagerServiceImpl ">
<property name= "persistenceManager ">
<ref bean= "persistenceManager " />
</property>
</bean>
其中persistenceManager来自applicationContext-dao.xml
<beans>
<bean id= "persistenceManager " class= "com.bytime.toss.framework.persistence.hibernate.HibernatePersistenceManager ">
<property name= "sessionFactory ">
<ref bean= "sessionFactory " />
</property>
</bean>
这样配置的时候一启动tomcat就报这个错:
2007-01-10 21:35:24,468 ERROR [main] context.ContextLoader (ContextLoader.java:114) - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'feeManagerService ' defined in ServletContext resource [/WEB-INF/app-config/applicationContext-service-afford.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required
java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required
如果把文件applicationContext-service-afford.xml改一下
<bean id= "feeManagerService " parent= "baseTxProxy ">
<property name= "target ">
<bean class= "com.bytime.toss.finance.charge.service.impl.FeeManagerServiceImpl " autowire= "byName " />
</property>
</bean>
就不会发生错误,我的FeeManagerServiceImpl类中需要persistenceManager,我不想让他自动根据名字来注入,而是想规规矩矩的进行注入为什么就不行呢
对应的FeeManagerServiceImpl类中的相关代码
public class FeeManagerServiceImpl extends HibernateDaoSupport implements FeeManagerService
{
static final Log log = LogFactory.getLog(FeeManagerServiceImpl.class);
private PersistenceManager persistenceManager;
public void setPersistenceManager(PersistenceManager persistenceManager)
{
this.persistenceManager = persistenceManager;
}
------解决方案--------------------
java.lang.IllegalArgumentException: sessionFactory or hibernateTemplate is required
-------------------------------------
sessionFactory还未装入,检查下hibernate是否在spring之前就已经装入了sessionFacatory,或者同楼上所说,直接在文件中写入sessionFactory.