Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse 在Red5中配置mybatis spring时出现问题_Eclipse_Spring_Red5_Mybatis - Fatal编程技术网

Eclipse 在Red5中配置mybatis spring时出现问题

Eclipse 在Red5中配置mybatis spring时出现问题,eclipse,spring,red5,mybatis,Eclipse,Spring,Red5,Mybatis,全部, 我正在尝试在Red5服务器下运行的应用程序中配置MyBatis。我在WEB-INF下创建了一个额外的spring配置文件red5 ibatis.xml,该文件配置了这些bean(如mybatis spring用户指南中所述): 我不确定,但Spring似乎没有看到SqlSessionFactoryBean实现FactoryBean接口,因此无法找到将其转换为SqlSessionFactory的方法 不管怎样,有什么办法可以解决吗?好的,看来我已经解决了。看起来我的应用程序WEB-INF/

全部,

我正在尝试在Red5服务器下运行的应用程序中配置MyBatis。我在
WEB-INF
下创建了一个额外的spring配置文件
red5 ibatis.xml
,该文件配置了这些bean(如mybatis spring用户指南中所述):

我不确定,但Spring似乎没有看到
SqlSessionFactoryBean
实现
FactoryBean
接口,因此无法找到将其转换为
SqlSessionFactory
的方法


不管怎样,有什么办法可以解决吗?

好的,看来我已经解决了。看起来我的应用程序
WEB-INF/lib
目录中有所有的Spring JAR,这可能是坏的,因为它们也在Red5
lib
文件夹中,所以它们是重复的。在弄乱了我的
ivy.xml
依赖项配置和Eclipse项目部署程序集设置之后,它开始工作

基本上,我必须从Eclipse项目中删除标准的
库/ivy.xml[*]
,并添加两个独立的库,在我的例子中是:
ivy.xml[runtime]
ivy.xml[compile]
。然后在我的Eclipse项目属性中,在“部署程序集”设置中,我选择只部署
ivy.xml[runtime]
中的依赖项,它不包含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