mybatis与spring整合报错Error creating bean with name 'sqlSessionFactory' defined in class path resource
2015-03-25 10:10
666 查看
今天做mybatis与spring整合的时候报了一个错误,如下
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlSessionFactory' defined in class path resource [config/applicationContext.xml]:
Cannot resolve reference to bean 'config/mybatis.xml' while setting bean property 'configLocation';
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'config/mybatis.xml' is defined
英文不太好,大体理解了一下,好像是说在applicationContext.xml中注册configLocation的地方有错
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation"
ref="config/mybatis.xml"></property>
</bean>
仔细检查了一下代码,发现还真是有错,唉,正确的代码如下
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="config/mybatis.xml"></property>
</bean>
给我一个支点,我能撬动整个地球,给我一个错误,我能搞挺整个项目
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/crazy.gif)
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlSessionFactory' defined in class path resource [config/applicationContext.xml]:
Cannot resolve reference to bean 'config/mybatis.xml' while setting bean property 'configLocation';
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'config/mybatis.xml' is defined
英文不太好,大体理解了一下,好像是说在applicationContext.xml中注册configLocation的地方有错
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation"
ref="config/mybatis.xml"></property>
</bean>
仔细检查了一下代码,发现还真是有错,唉,正确的代码如下
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="config/mybatis.xml"></property>
</bean>
给我一个支点,我能撬动整个地球,给我一个错误,我能搞挺整个项目
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/crazy.gif)
相关文章推荐
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- 错误Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.
- Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Error creating bean with name 'sessionFactory' defined in class path resource [beans.xml]: Invocatio
- springMVC+mybatis 进行单元测试时 main SqlSessionFactoryBean - Parsed configuration file: 'class path resource' 无限的读取xml文件
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xm
- Error creating bean with name 'sessionFactory' defined in class path resource
- SSH整合异常解决(creating bean with name 'sessionFactory' defined in class path)
- Error creating bean with name 'mySessionFactory' defined in class path resource [applicationContext.xml]:
- 一、Error creating bean with name 'hsFactory' defined in class path resource [xxx.xml]:
- Error creating bean with name 'sqlSessionFactory' defined in ServletContext resource
- 解决错误Error creating bean with name 'MySessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init
- Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext
- FAQ(27):Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicatio
- Intellij idea:Error creating bean with name 'sqlSessionFactory' defined in class path resource
- ssh框架搭建Error creating bean with name 'sessionFactory' defined in class path
- Error creating bean with name 'sqlSessionFactory' defined in class path resource
- ssm出现Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring/applic