Current environment :

SpringBoot > 3.0.5 GraalVM > GraalVM CE 22.3.1 (build 17.0.6+10-jvmci-22.3-b13) Mybatis > 3.5.10 Mybatis-Spring > 2.0.7

Configuration related to plug-ins:

<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>org.graalvm.buildtools</groupId>
        <artifactId>native-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>

Problem: when i execute the mvn clean native:compile -Pnative command, the following error will occur

Exception in thread "main" org.springframework.boot.context.properties.bind.MissingParametersCompilerArgumentException: Constructor binding in a native image requires compilation with -parameters but the following classes were compiled without it:
    org.apache.ibatis.mapping.ResultFlag
    org.apache.ibatis.builder.CacheRefResolver
    org.apache.ibatis.builder.annotation.MethodResolver
    org.apache.ibatis.parsing.XNode
    org.apache.ibatis.builder.ResultMapResolver
    at org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar.registerHints(BindableRuntimeHintsRegistrar.java:87)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBeanFactoryInitializationAotProcessor$ConfigurationPropertiesReflectionHintsContribution.applyTo(ConfigurationPropertiesBeanFactoryInitializationAotProcessor.java:70)
    at org.springframework.context.aot.BeanFactoryInitializationAotContributions.applyTo(BeanFactoryInitializationAotContributions.java:78)
    at org.springframework.context.aot.ApplicationContextAotGenerator.lambda$processAheadOfTime$0(ApplicationContextAotGenerator.java:58)
    at org.springframework.context.aot.ApplicationContextAotGenerator.withCglibClassHandler(ApplicationContextAotGenerator.java:67)
    at org.springframework.context.aot.ApplicationContextAotGenerator.processAheadOfTime(ApplicationContextAotGenerator.java:53)
    at org.springframework.context.aot.ContextAotProcessor.performAotProcessing(ContextAotProcessor.java:106)
    at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:84)
    at org.springframework.context.aot.ContextAotProcessor.doProcess(ContextAotProcessor.java:49)
    at org.springframework.context.aot.AbstractAotProcessor.process(AbstractAotProcessor.java:82)
    at org.springframework.boot.SpringApplicationAotProcessor.main(SpringApplicationAotProcessor.java:76)

Comment From: scottfrederick

@bigdog001 It appears that something in your application is trying to use a class from iBATIS as a field in a @ConfigurationProperties class, and is also using constructor binding. The Spring Boot documentation calls out this requirement:

To use constructor binding in a native image the class must be compiled with -parameters. This will happen automatically if you use Spring Boot’s Gradle plugin or if you use Maven and spring-boot-starter-parent.

If this @ConfigurationProperties class is in your code, then you can avoid using the iBATIS class directly in your configuration properties, or use Java bean properties binding instead of constructor binding for your configuration properties class. If the @ConfigurationProperties class is in another library, you will need to contact that library vendor for support.

If you think there is something else going on that Spring Boot can control, please provide a complete minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it and attaching it to this issue.

Comment From: snicoll

@bigdog001 also, this error should go away if you upgrade to the latest MyBatis version, see https://github.com/mybatis/mybatis-3/issues/2858. I am going to close this now as I believe it's outside of Spring Boot's control.

Comment From: bigdog001

thanks so much about those replies .