无需任何注解和配置,解决native-image编译运行问题#7017
Open
xiaochenxt wants to merge 5 commits into
Open
Conversation
|
这个能合并吗? 需要这个功能 |
There was a problem hiding this comment.
Pull request overview
该 PR 新增 mybatis-plus-spring-boot-native-image 模块,通过 Spring AOT RuntimeHints + GraalVM Feature/资源注册,目标是在无需额外注解与配置的情况下,解决 MyBatis / MyBatis-Plus 在 native-image 编译与运行中的反射、资源与代理问题,并同时适配 Spring Boot 3/4 的 starter 依赖链。
Changes:
- 新增
mybatis-plus-spring-boot-native-image模块:提供 AutoConfiguration、RuntimeHintsRegistrar、GraalVM Feature 以及资源配置文件。 - 将 native-image 模块作为
api依赖引入mybatis-plus-spring-boot3-starter与mybatis-plus-spring-boot4-starter。 - 在
settings.gradle与mybatis-plus-bom中注册/纳入该新模块。
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| spring-boot-starter/mybatis-plus-spring-boot4-starter/build.gradle | 为 Boot4 starter 增加 native-image 模块依赖 |
| spring-boot-starter/mybatis-plus-spring-boot3-starter/build.gradle | 为 Boot3 starter 增加 native-image 模块依赖 |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/build.gradle | 定义新模块的编译版本与依赖(含 nativeimage / 测试依赖) |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/java/com/baomidou/mybatisplus/aot/MyBatisPlusNativeImageConfiguration.java | AOT 期间处理 MapperFactoryBean、注册反射/代理/关联类型 |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/java/com/baomidou/mybatisplus/aot/MybatisPlusFeature.java | GraalVM Feature:注册序列化、反射、资源与代理相关配置 |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/java/com/baomidou/mybatisplus/aot/MyBaitsRuntimeHintsRegistrar.java | RuntimeHintsRegistrar:注册 XML 资源 hints |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/java/com/baomidou/mybatisplus/aot/FeatureUtils.java | native-image hosted API 注册辅助工具 |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/java/com/baomidou/mybatisplus/aot/CollectUtils.java | 类/资源扫描与收集工具(Feature/AOT 使用) |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/java/com/baomidou/mybatisplus/aot/AotUtils.java | Spring RuntimeHints 注册辅助工具 |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports | 导出 AutoConfiguration |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/resources/META-INF/spring/aot.factories | 注册 RuntimeHintsRegistrar |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/src/main/resources/META-INF/native-image/com.baomidou/mybatis-plus-spring-boot-native-image/native-image.properties | 配置 native-image --features |
| spring-boot-starter/mybatis-plus-spring-boot-native-image/src/test/java/RuntimeHintsRegistrarTest.java | 新增 RuntimeHintsRegistrar 基础测试(当前无断言) |
| settings.gradle | include 新模块 |
| mybatis-plus-bom/build.gradle | BOM 增加新模块依赖声明 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Author
|
这个模块的代码不参与运行时,只在spring-boot:process-aot和native-image编译期间生效,不会影响任何业务代码,没必要搞那么谨慎 |
Author
我发布过dc-spring-boot-native-image,你可以在maven仓库搜,0.1开头的版本是springboot3的,0.4开头的版本是springboot4的,除了mybatis,还支持了awt相关的字体、图片、jpa、caffeine等。原先编译后运行报错的,引入后大多都可以解决 |
|
遇到同样问题 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
新增mybatis-plus-spring-boot-native-image模块,适配springboot3和springboot4