我有以下标准配置:
<bean id="globalSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource"></ref>
</property>
<property name="mappingResources">
<list>
<value>...</value>
</list>
</property>
</bean>
在另一个模块中:
<bean id="configurationSettingsService" class="com.HibernateConfigurationSettingsService">
<property name="sessionFactory" ref="globalSessionFactory"/>
</bean>
使用会话工厂的类:
public class HibernateConfigurationSettingsService implements ConfigurationSettingsService {
private HibernateTemplate hibernateTemplate;
private SessionFactory sessionFactory;
public SessionFactory getSessionFactory() {
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
this.hibernateTemplate = new HibernateTemplate(sessionFactory);
}
类路径上只有libs的版本是:
休眠3.5.4-决赛 春天3.2.3.RELEASE
尝试在Tomee中运行应用程序(使用tomcat 7),得到以下错误:
Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of ty
pe 'org.springframework.orm.hibernate3.LocalSessionFactoryBean' to required type 'org.hibernate.SessionFactory' for property 'sessionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.springframework.orm.hibernate3.LocalSessionFactoryBean] to required type [org.hibernate.S
essionFactory] for property 'sessionFactory': no matching editors or conversion strategy found
任何人都知道为什么Spring不会在这里重新调整SessionFactory的实例?
谢谢大家。
解决!问题是在两个类路径上有弹簧库,只要我设置了单独的模块依赖项,一切都很好。