Search code examples
javaspringspring-bootmybatisspring-mybatis

Spring Boot with MyBatis - @MapperScan error


I am trying to set up Spring Boot with MyBatis. When I try and launch my application, I am getting the following error:

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)

I'm using the following versions in my pom.xml in order to get things set up:

  • spring-boot-dependencies @ 1.5.9.RELEASE
  • spring-cloud-dependencies @ Edgware.SR1
  • mybatis @ 3.4.5
  • mybatis-spring @ 1.3.1

I also have the following included:

  • mybatis-spring-boot-starter
  • spring-boot-configuration-processor
  • spring-cloud-config-client
  • spring-boot-starter-web
  • spring-boot-starter-actuator
  • spring-boot-starter

I'm not sure if there is a conflict or what, but it's not letting me set up my mappers. Any suggestions are happily welcomed.


Solution

  • OK - so the problem is a conflict between mybatis @ 3.4.5 and mybatis-spring @ 1.3.1.

    When I dropped mybatis @ 3.4.5 everything worked just fine.