nacos-group / nacos-spring-boot-project

Nacos ECO Project for Spring Boot
Apache License 2.0
783 stars 423 forks source link

[ISSUE #10375] Support springboot3 and native-image #302

Closed SuperZ1999 closed 11 months ago

SuperZ1999 commented 11 months ago

Please do not create a Pull Request without creating an issue first.

What is the purpose of the change

适配springboot3 和 native-image

Brief changelog

适配SpringBoot3

根据SpringBoot3的自动配置方式,添加org.springframework.boot.autoconfigure.AutoConfiguration.imports文件,然后更新依赖的nacos-spring-context版本

支持native-image

添加native-image编译所需的配置文件,然后导入nacos-spring-context-aot依赖

Verifying this change

适配SpringBoot3

首先将https://nacos.io/zh-cn/docs/nacos-spring.html里的功能都debug测试一遍,debug时统计没有走到的代码,然后运行所有单元测试即可测试上述没有走到的代码

支持native-image

新建一个项目,导入所有starter和actuator项目,开启GraalVM的Tracing Agent功能(运行java程序时添加参数:-agentlib:native-image-agent=config-output-dir=/path/to/config-dir/),将https://nacos.io/zh-cn/docs/nacos-spring.html里的功能测试一遍,之后将生成的配置文件拷贝到META-INF/native-image下,再使用spring-boot-maven-plugin的process-aot和native-maven-plugin的compile功能,运行mvn clean package -Pnative即可生成可执行程序。 运行生成的可执行程序,再将https://nacos.io/zh-cn/docs/nacos-spring.html里的功能测试一遍,功能正常即测试通过

Follow this checklist to help us incorporate your contribution quickly and easily:

hujun-w-2 commented 11 months ago

It looks good, add user usage documents and submit a PR.