我试着在我的spring项目中使用mybatis.xml,但我想知道一件事:要读取mybatis,applicationContext需要配置吗?
下面是我的xml:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="com.Ordering.Model" />
<property name="mapperLocations" value="classpath:mapper/*.xml" />
</bean>如果我添加此配置:
<property name="configuration" value="classpath:mybatis/mybatis-config.xml" />我会得到这样的信息:
Failed to convert property value of type 'java.lang.String' to required type 'org.apache.ibatis.session.Configuration'当我移除它时,没有任何问题。我是否需要任何配置来转换mybatis.xml。
发布于 2016-12-14 15:47:52
您为configuration属性配置了错误的类型,它不是Strting,您应该使用org.apache.ibatis.session.Configuration对其进行配置,如下所示的内部bean:
<property name="configuration">
<bean class="org.apache.ibatis.session.Configuration">
....
</bean>
</property>看起来您真正想要的是配置configLocation属性。
发布于 2016-12-14 15:49:12
我已经找到问题所在了。
删除此配置:
<property name="configuration" value="classpath:mybatis/mybatis-config.xml" />而不是:
<property name="configLocation" value="classpath:mybatis/mybatis-config.xml"/>https://stackoverflow.com/questions/41137076
复制相似问题