when I integrate spring and mybatis, I encountered a error output, saying that:
Bean named 'sqlSessionFactory' must be of type [org.mybatis.spring.SqlSessionFactoryBean], but was actually of type [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory]
here is my code snippet:
ApplicationContext context = new ClassPathXmlApplicationContext("spring_mybatis_integration/spring_config.xml");
SqlSessionFactoryBean sqlSessionFactoryBean = context.getBean("sqlSessionFactory", org.mybatis.spring.SqlSessionFactoryBean.class);
here is my bean definition in xml:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="spring_mybatis_integration/mybatis_config.xml"></property>
<property name="dataSource" ref="dataSource"></property>
</bean>
as you can see, both in java code and in xml file, I associate the bean sqlSessionFactory with class org.mybatis.spring.SqlSessionFactoryBean, why does the error output tell me another non-relative class name org.apache.ibatis.session.defaults.DefaultSqlSessionFactory?
Thanks a lot!
Version Info:
- mybatis 3.1.1
- spring 3.2.0
- mybatis-spring 1.1.1