有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Spring启动时出现MyBatis@MapperScan错误

我正试着用MyBatis安装Spring Boot。当我尝试启动应用程序时,出现以下错误:

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中使用了以下版本,以便进行设置:

  • spring启动依赖项@1.5.9。释放
  • spring cloud dependencies@Edgware。SR1
  • mybatis@3.4.5
  • mybatis spring@1.3.1

我还包括以下内容:

  • 迈巴蒂斯弹簧靴起动器
  • spring引导配置处理器
  • spring云配置客户端
  • SpringBootStarterWeb
  • 弹簧靴起动器执行器
  • 弹簧靴起动器

我不确定是否有冲突或什么,但它不允许我设置映射器。欢迎提出任何建议


共 (3) 个答案

  1. # 2 楼答案

    好的-所以问题是mybatis@3.4.5mybatis spring@1.3.1之间的冲突

    当我放下mybatis@3.4.5时,一切都很顺利

  2. # 3 楼答案

    您需要添加此maven依赖项:

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