Error creating bean with name ‘sqlsessionfactory’ defined in class path resource

Today, I made an error when integrating mybatis with spring, as follows:

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

My English is not very good. I understand it in general applicationContext.xml There is an error registering configlocation in

<bean id=”sqlSessionFactory” class=” org.mybatis.spring .SqlSessionFactoryBean”>
<property name=”dataSource” ref=”dataSource”></property>
<property name=”configLocation” ref=”config/ mybatis.xml “></property>
</bean>

After a careful examination of the code, I found that there was something wrong. Alas, the correct code is as follows

<bean id=”sqlSessionFactory” class=” org.mybatis.spring .SqlSessionFactoryBean”>
<property name=”dataSource” ref=”dataSource”></property>
<property name=”configLocation” value=”config/ mybatis.xml “></property>
</bean>

Give me a fulcrum, I can pry the whole earth, give me a mistake, I can support the whole project

Read More: