質問

全て、

RED5サーバーで実行されているアプリケーションでMyBatisを構成しようとしています。追加のスプリング構成ファイルを作成しました red5-ibatis.xmlWEB-INF これらの豆は構成されています(mybatis-springユーザーガイドで説明されています):

<bean id="hsqldbDataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <property name="driverClassName" value="org.hsqldb.jdbcDriver" />
    <property name="url" value="jdbc:hsqldb:file:./db/hsqldb/testdb" />
    <property name="username" value="sa" />
    <property name="password" value="" />
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="hsqldbDataSource" />
</bean>

<bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
    <property name="mapperInterface" value="test.mappers.UserMapper" />
    <property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>

アプリを展開してサーバーを実行すると、次の例外が表示されます。

Exception in thread "Launcher:/testapp" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userMapper' defined in ServletContext resource [/WEB-INF/red5-ibatis.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.mybatis.spring.SqlSessionFactoryBean' to required type 'org.apache.ibatis.session.SqlSessionFactory' for property 'sqlSessionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.mybatis.spring.SqlSessionFactoryBean] to required type [org.apache.ibatis.session.SqlSessionFactory] for property 'sqlSessionFactory': no matching editors or conversion strategy found
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at org.red5.server.tomcat.TomcatLoader$1.run(TomcatLoader.java:594)
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.mybatis.spring.SqlSessionFactoryBean' to required type 'org.apache.ibatis.session.SqlSessionFactory' for property 'sqlSessionFactory'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.mybatis.spring.SqlSessionFactoryBean] to required type [org.apache.ibatis.session.SqlSessionFactory] for property 'sqlSessionFactory': no matching editors or conversion strategy found
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:462)
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:499)
    at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:493)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1371)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1330)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1086)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    ... 9 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [org.mybatis.spring.SqlSessionFactoryBean] to required type [org.apache.ibatis.session.SqlSessionFactory] for property 'sqlSessionFactory': no matching editors or conversion strategy found
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:231)
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:447)
    ... 15 more

よくわかりませんが、春は SqlSessionFactoryBean 実装します FactoryBean インターフェイスなので、それを変換する方法を見つけることができません SqlSessionFactory?

とにかく、それを修正する方法はありますか?

役に立ちましたか?

解決

わかりました、私はそれを解決したようです。アプリにすべての春の瓶があったようです WEB-INF/lib ディレクトリ、それはおそらくred5にあるために悪いことでした lib フォルダーなので、それらは複製されました。私をいじった後 ivy.xml 依存関係の構成とEclipseプロジェクトの展開アセンブリ設定が機能し始めました。

基本的に標準を削除する必要がありました Libraries/ivy.xml [*] 私の日食プロジェクトから、2つの別々のプロジェクトを追加してください。私の場合は次のとおりです。 ivy.xml [runtime]ivy.xml [compile]. 。次に、Eclipse Projectプロパティで、「展開アセンブリ」設定では、依存症のみを展開することを選択しました。 ivy.xml [runtime], 、スプリングライブラリは含まれていません。

これ以上例外はありません。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top