Is java.lang.NoClassDefFoundError: org / apache / ibatis / session / SqlSessionFactory with mybatis and Spring

I am new to Mybatis and trying to implement mybatis using Spring, but I get the following runtime error when starting tomcat.

Here is my pom.xml

 <dependency> <groupId>c3p0</groupId> <artifactId>c3p0</artifactId> <version>0.9.1.2</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.0.0</version> </dependency> 

and application context:

 <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="uactivityDS"/> <property name="configLocation" value="classpath:mybatis-config.xml"/> </bean> 

Error:

 the resource [applicationContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/apache/ibatis/session/SqlSessionFactory 

The file mybatis-spring-1.0.0.jar exists in war/web-inf/lib .

Any idea what is going on in this scenario?

+6
source share
1 answer

If you look at pom.xml for mybatis-spring -1.0.0.jar, it has a compile time dependency of mybatis 3.0.4, which contains the class org / apache / ibatis / session / SqlSessionFactory.

So include this jar along with the others mentioned in pom.xml and you should be good.

+4
source

Source: https://habr.com/ru/post/919529/


All Articles