Run [spring-boot:process-aot] to report an error :

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.4.0)
2024-12-13 17:12:43.168  WARN 28416 --- [           main][] o.m.s.mapper.ClassPathMapperScanner      : Skipping MapperFactoryBean with name 'testMapper' and 'com.digital.ass.domain.mapper.TestMapper' mapperInterface. Bean already defined with the same name!
2024-12-13 17:12:43.169  WARN 28416 --- [           main][] o.m.s.mapper.ClassPathMapperScanner      : Skipping MapperFactoryBean with name 'partsMapper' and 'com.digital.ass.service.basic.domain.mapper.PartsMapper' mapperInterface. Bean already defined with the same name!
2024-12-13 17:12:43.171  WARN 28416 --- [           main][] o.m.s.mapper.ClassPathMapperScanner      : No MyBatis mapper was found in '[com.digital.ass]' package. Please check your configuration.
Exception in thread "main" org.springframework.beans.factory.aot.AotBeanProcessingException: Error processing bean with name 'testMapper' defined in file [D:\workspace\com.waitylyou\after-sales-service\target\classes\com\digital\ass\domain\mapper\TestMapper.class]: failed to generate code for bean definition
    at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution$BeanDefinitionsRegistrationGenerator.lambda$generateRegisterBeanDefinitionMethods$2(BeanRegistrationsAotContribution.java:217)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution$BeanDefinitionsRegistrationGenerator.generateRegisterBeanDefinitionMethods(BeanRegistrationsAotContribution.java:207)
    at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution$BeanDefinitionsRegistrationGenerator.lambda$generateRegisterBeanDefinitionsMethod$0(BeanRegistrationsAotContribution.java:171)
    at org.springframework.aot.generate.GeneratedMethod.<init>(GeneratedMethod.java:54)
    at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:112)
    at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:89)
    at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution$BeanDefinitionsRegistrationGenerator.generateRegisterBeanDefinitionsMethod(BeanRegistrationsAotContribution.java:166)
    at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution.applyTo(BeanRegistrationsAotContribution.java:77)
    at org.springframework.context.aot.BeanFactoryInitializationAotContributions.applyTo(BeanFactoryInitializationAotContributions.java:96)
    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:80)
Caused by: org.springframework.aot.generate.ValueCodeGenerationException: Failed to generate code for 'tk.mybatis.mapper.mapperhelper.MapperHelper@22da2fe6' with type class tk.mybatis.mapper.mapperhelper.MapperHelper
    at org.springframework.aot.generate.ValueCodeGenerator.generateCode(ValueCodeGenerator.java:121)
    at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.generateValue(BeanDefinitionPropertiesCodeGenerator.java:280)
    at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.addPropertyValues(BeanDefinitionPropertiesCodeGenerator.java:239)
    at org.springframework.beans.factory.aot.BeanDefinitionPropertiesCodeGenerator.generateCode(BeanDefinitionPropertiesCodeGenerator.java:145)
    at org.springframework.beans.factory.aot.DefaultBeanRegistrationCodeFragments.generateSetBeanDefinitionPropertiesCode(DefaultBeanRegistrationCodeFragments.java:176)
    at org.springframework.beans.factory.aot.BeanRegistrationCodeGenerator.generateCode(BeanRegistrationCodeGenerator.java:81)
    at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.lambda$generateBeanDefinitionMethod$3(BeanDefinitionMethodGenerator.java:176)
    at org.springframework.aot.generate.GeneratedMethod.<init>(GeneratedMethod.java:54)
    at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:112)
    at org.springframework.aot.generate.GeneratedMethods.add(GeneratedMethods.java:89)
    at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:169)
    at org.springframework.beans.factory.aot.BeanDefinitionMethodGenerator.generateBeanDefinitionMethod(BeanDefinitionMethodGenerator.java:94)
    at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution$BeanDefinitionsRegistrationGenerator.generateBeanRegistration(BeanRegistrationsAotContribution.java:226)
    at org.springframework.beans.factory.aot.BeanRegistrationsAotContribution$BeanDefinitionsRegistrationGenerator.lambda$generateRegisterBeanDefinitionMethods$2(BeanRegistrationsAotContribution.java:209)
    ... 17 more
Caused by: org.springframework.aot.generate.UnsupportedTypeValueCodeGenerationException: Code generation does not support tk.mybatis.mapper.mapperhelper.MapperHelper
    at org.springframework.aot.generate.ValueCodeGenerator.generateCode(ValueCodeGenerator.java:118)
    ... 30 more

Comment From: snicoll

@admintertar thanks for the report but please refrain from posting source code like that. I've edited to remove the code of the class.

If you want support, the best is to provide a small sample that we can run ourselves. You can attach a zip to this issue or push the code to a GitHub repository. This will let us figure out if the MyBatis integration is responsible for trying to serialize MapperHelper (we obviously can't figure out how to do that automatically).

Comment From: admintertar

@snicoll Thank you for your reply, this is my demo, just run mvn -Pnative native:compile java-version: GraalVM 21.0.4

win-native.zip

Comment From: snicoll

Thank you for the sample. @Mapper is a MyBatis component. It should handle things in such a way that's compatible with Spring AOT (and then native). Please review https://github.com/mybatis/spring-native and adapt your project accordingly. If that still does not work, please report that issue there.