mybatis與spring整合報錯Error creating bean with name 'sqlSessionFactory' defined in class path resource,mybatisbean

來源:互聯網
上載者:User

mybatis與spring整合報錯Error creating bean with name 'sqlSessionFactory' defined in class path resource,mybatisbean

今天做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>

給我一個支點,我能撬動整個地球,給我一個錯誤,我能搞挺整個項目

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.