mybatis / spring-boot-starter

MyBatis integration with Spring Boot
Apache License 2.0
4.14k stars 1.79k forks source link

:sparkles: Support MyBatis for Spring Boot 3 Native #994

Open xuxiaowei-com-cn opened 3 months ago

xuxiaowei-com-cn commented 3 months ago

Premise

  1. org.springframework.experimental:spring-aot Repository: https://github.com/spring-attic/spring-native : EOL
  2. org.springframework.experimental:spring-aot Repository: https://github.com/spring-attic/spring-native : This project is now superseded by Spring Boot 3+ official native support, see the related reference documentation for more details.
  3. org.springframework.experimental:spring-aot Repository: https://github.com/spring-attic/spring-native : Only supports Spring Boot 2, not Spring Boot 3
  4. org.mybatis.spring.native:mybatis-spring-native-core Repository: https://github.com/mybatis/spring-native : Used org.springframework.experimental:spring-aot

前提

  1. org.springframework.experimental:spring-aot 仓库: https://github.com/spring-attic/spring-native : 寿命终止
  2. org.springframework.experimental:spring-aot 仓库: https://github.com/spring-attic/spring-native : 该项目现已被 Spring Boot 3+ 官方原生支持所取代,请参阅 相关参考文档 了解更多详情。
  3. org.springframework.experimental:spring-aot 仓库: https://github.com/spring-attic/spring-native : 仅支持 Spring Boot 2,不支持 Spring Boot 3
  4. org.mybatis.spring.native:mybatis-spring-native-core 仓库: https://github.com/mybatis/spring-native : 使用了 org.springframework.experimental:spring-aot

Principle

  1. Use the following configuration file types as much as possible to avoid affecting the project in non native scenarios as much as possible
    1. reflect-config.json
    2. jni-config.json
    3. resource-config.json
    4. proxy-config.json
    5. serialization-config.json
    6. preset-classes-config.json
  2. Try to automatically configure and use it out of the box to avoid burdening users

原则

  1. 尽量多的使用以下配置文件类型,尽可能的避免在非 native 场景下影响项目
    1. reflect-config.json
    2. jni-config.json
    3. resource-config.json
    4. proxy-config.json
    5. serialization-config.json
    6. preset-classes-config.json
  2. 尽量自动配置,开箱即用,避免对使用者造成负担

New Features

  1. Increase Native pipeline construction and product testing, including: Ubuntu/MacOS GraalVM JDK 17/21/22
  2. When adding native builds, mybatis.comnfig-location is configured to recognize and automatically import resource files
  3. When adding native builds, mybatis.mapper-locations is configured to recognize and automatically import resource files
  4. Add dynamic proxy for Mapper interface when building Native
  5. When adding native builds, the default type of returned data is automatically reflected, including:
    1. java.util.ArrayList
    2. java.util.HashMap
    3. java.util.TreeSet
    4. java.util.HashSet
  6. When adding native builds, return data with custom types for automatic reflection
  7. When adding native builds, ibatis logging automatically reflects:
    1. org.apache.ibatis.logging.slf4j.Slf4jImpl
    2. org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl
    3. org.apache.ibatis.logging.log4j2.Log4j2Impl
    4. org.apache.ibatis.logging.log4j.Log4jImpl
    5. org.apache.ibatis.logging.jdk14.Jdk14LoggingImpl
    6. org.apache.ibatis.logging.nologging.NoLoggingImpl
  8. When adding native builds, the required class reflection is:
    1. org.apache.ibatis.plugin.Interceptor
    2. org.apache.ibatis.javassist.util.proxy.ProxyFactory
    3. org.apache.ibatis.scripting.xmltags.XMLLanguageDriver
    4. org.apache.ibatis.scripting.defaults.RawLanguageDriver
    5. org.mybatis.spring.SqlSessionFactoryBean
    6. org.apache.ibatis.session.Configuration
    7. org.mybatis.spring.boot.autoconfigure.SpringBootVFS
  9. Add static resource import when building Native
    1. org/apache/ibatis/builder/xml/mybatis-3-config.dtd
    2. org/apache/ibatis/builder/xml/mybatis-3-mapper.dtd
    3. org/apache/ibatis/builder/xml/mybatis-config.xsd
    4. org/apache/ibatis/builder/xml/mybatis-mapper.xsd
  10. When adding native builds, MyBatis annotation examples are supported
  11. When adding native builds, MyBatis XML examples support

新功能

  1. 增加 Native 流水线构建、产物测试,包含:Ubuntu/MacOS GraalVM JDK 17/21/22
  2. 增加 Native 构建时,mybatis.config-location 配置识别,自动执行资源文件导入
  3. 增加 Native 构建时,mybatis.mapper-locations 配置识别,自动执行资源文件导入
  4. 增加 Native 构建时,Mapper 接口动态代理
  5. 增加 Native 构建时,返回数据默认类型自动反射,包含:
    1. java.util.ArrayList
    2. java.util.HashMap
    3. java.util.TreeSet
    4. java.util.HashSet
  6. 增加 Native 构建时,返回数据自定义类型自动反射
  7. 增加 Native 构建时,ibatis logging 自动反射:
    1. org.apache.ibatis.logging.slf4j.Slf4jImpl
    2. org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl
    3. org.apache.ibatis.logging.log4j2.Log4j2Impl
    4. org.apache.ibatis.logging.log4j.Log4jImpl
    5. org.apache.ibatis.logging.jdk14.Jdk14LoggingImpl
    6. org.apache.ibatis.logging.nologging.NoLoggingImpl
  8. 增加 Native 构建时,所需 class 反射:
    1. org.apache.ibatis.plugin.Interceptor
    2. org.apache.ibatis.javassist.util.proxy.ProxyFactory
    3. org.apache.ibatis.scripting.xmltags.XMLLanguageDriver
    4. org.apache.ibatis.scripting.defaults.RawLanguageDriver
    5. org.mybatis.spring.SqlSessionFactoryBean
    6. org.apache.ibatis.session.Configuration
    7. org.mybatis.spring.boot.autoconfigure.SpringBootVFS
  9. 增加 Native 构建时,静态资源导入
    1. org/apache/ibatis/builder/xml/mybatis-3-config.dtd
    2. org/apache/ibatis/builder/xml/mybatis-3-mapper.dtd
    3. org/apache/ibatis/builder/xml/mybatis-config.xsd
    4. org/apache/ibatis/builder/xml/mybatis-mapper.xsd
  10. 增加 Native 构建时,MyBatis annotation 示例支持
  11. 增加 Native 构建时,MyBatis xml 示例支持
xuxiaowei-com-cn commented 3 months ago

I added a pipeline based on Ubuntu and macOS for testing native applications, and it has now passed the test

https://github.com/xuxiaowei-com-cn/mybatis-spring-boot-starter/actions/workflows/native.yaml

xuxiaowei-com-cn commented 3 months ago

I personally develop my computer using Windows. The Windows pipeline requires the following conditions, which I have not been able to solve yet.

我个人开发使用 Windows 电脑。 Windows 运行需要安装以下软件,流水线尚未解决。