Spring 使用 MyBatis 启动 - @MapperScan 错误

Spring Boot with MyBatis - @MapperScan error

我正在尝试设置 Spring 使用 MyBatis 启动。当我尝试启动我的应用程序时,出现以下错误:

java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.mybatis.spring.annotation.MapperScan.factoryBean()
    at java.lang.reflect.Method.getDefaultValue(Method.java:611)
    at sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:128)
    at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:85)     
    at ...
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:301)
    at com.mydomain.Server.launch(Server.java:70)
    at com.mydomain.Server.main(Server.java:93)

我在 pom.xml 中使用以下版本进行设置:

我还有以下内容:

我不确定是否存在冲突或其他原因,但它不允许我设置我的映射器。欢迎任何建议。

OK - 所以问题是 mybatis @ 3.4.5mybatis-spring @1.3.1[=17= 之间的冲突].

当我删除 mybatis @ 3.4.5 时一切正常。

我遇到了同样的问题。
我试过mybatis-spring-boothttps://mvnrepository.com/artifact/org.mybatis.spring.boot/mybatis-spring-boot-starter/1.3.2
我的应用程序 运行 可以。

希望对你有所帮助

你需要添加这个maven依赖:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
</dependency>