Springboot启动报错:Correct the classpath of your application so that it contains compatible versions of the classes org.mybatis.spring
报错信息:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:564)
The following method did not exist:
org.apache.ibatis.session.Configuration.setDefaultEnumTypeHandler(Ljava/lang/Class;)V
The calling method's class, org.mybatis.spring.SqlSessionFactoryBean, was loaded from the following location:
jar:file:/D:/repo/org/mybatis/mybatis-spring/2.0.7/mybatis-spring-2.0.7.jar!/org/mybatis/spring/SqlSessionFactoryBean.class
The called method's class, org.apache.ibatis.session.Configuration, is available from the following locations:
jar:file:/D:/repo/org/mybatis/mybatis/3.4.2/mybatis-3.4.2.jar!/org/apache/ibatis/session/Configuration.class
The called method's class hierarchy was loaded from the following locations:
org.apache.ibatis.session.Configuration: file:/D:/repo/org/mybatis/mybatis/3.4.2/mybatis-3.4.2.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes org.mybatis.spring.SqlSessionFactoryBean and org.apache.ibatis.session.Configuration
原因:引用了多个相同包,导致冲突
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.2</version>
</dependency>
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>${tk.version}</version>
</dependency>
解决办法:删除以上引入的两个包其中的一个。
浙公网安备 33010602011771号