2

次の標準構成があります。

<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);
}

クラスパス上のライブラリのバージョンのみ:

hibernate 3.5.4-Final spring 3.2.3.RELEASE

(tomcat 7 を使用して) Tomee でアプリケーションを実行しようとすると、次のエラーが発生します。

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 のインスタンスを返さない理由を知っている人はいますか?

皆さんありがとう。

解決しました!問題は、2 つのクラスパスにスプリング ライブラリを配置することでした。個々のモジュールの依存関係を提供に設定するとすぐに、すべてがうまくいきました。

4

0 に答える 0