2011-09-05 7 views
0

모두Red5에서 mybatis-spring 구성 문제

Red5 서버에서 실행되는 응용 프로그램에서 MyBatis를 구성하려고합니다. 나는 (MyBatis로 스프링 사용 설명서에 설명 된대로) 구성이 콩이있는 WEB-INF에서 추가 스프링 설정 파일 red5-ibatis.xml을 만들어 :

<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 

잘 모르겠어요,하지만 봄이 SqlSessionFactoryBeanSqlSessionFactory로 변환 할 수있는 방법을 찾을 수 있도록 FactoryBean 인터페이스를 구현하고 있음을 볼 수없는 것 같습니다?

어쨌든, 어떤 아이디어로 해결할 수 있습니까?

답변

0

좋아요, 해결 됐습니다. 내 애플 리케이션 WEB-INF/lib 디렉토리에있는 모든 Spring jars를 가지고있는 것처럼 보이는데, 이는 아마도 Red5 lib 폴더에 있기 때문에 나쁘다. 그래서 그들은 복제되었다. 내 ivy.xml 종속성 구성과 내 Eclipse 프로젝트 전개 어셈블리 설정을 망친 후에 작업이 시작되었습니다.

기본적으로 내 Eclipse 프로젝트에서 표준 Libraries/ivy.xml [*]을 제거하고 별도의 두 가지를 추가해야했습니다. 제 경우에는 ivy.xml [runtime]ivy.xml [compile]이었습니다. 그런 다음 내 Eclipse 프로젝트 속성에서 "배포 어셈블리"설정에서 스프링 라이브러리가 포함되지 않은 ivy.xml [runtime]의 종속 파일 만 배포하기로했습니다.

더 이상 예외는 없습니다.