mybatisguicejava-17

MyBatis-Guice fails to initialize with java 17


I am getting the following exception when starting mybatis with java17.

java.lang.NoSuchMethodError: 'void org.mybatis.guice.AbstractMyBatisModule.bindInterceptor(com.google.inject.matcher.Matcher, com.google.inject.matcher.Matcher, org.aopalliance.intercept.MethodInterceptor[])'

Maven dependencies:

<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.5.11</version>
</dependency>
<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-guice</artifactId>
    <version>3.18</version>
</dependency>
<dependency>
    <groupId>com.google.inject</groupId>
    <artifactId>guice</artifactId>
    <version>5.1.0</version>
</dependency>

Solution

  • The issue there was a 3rd party dependency that was pulling in guice no_aop from 4.0.1. once excluded it worked fine.

    Verify no guice dependencies using

    mvn dependency:tree