错误信息:
java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.mybatis.spring.annotation.MapperScan.factoryBean()
错误原因:包引用错误。@MapperScan注解引用的并不是mybatis-spring:1.2.3这个包。这算不算idea的bug?为什么有时候idea提示的又是正确的mybatis-spring-boot-starter那个?
将pom文件中的
idea 提示自动添加的
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.3</version>
<scope>compile</scope>
</dependency>
改为下面的即可
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.4</version>
</dependency>