feat(springboot3): 添加 RefreshScope 自动配置支持

- 新增 KenaitoRefreshAutoConfiguration 类,实现 ApplicationContextAware
- 更新 spring.factories,注册 EnableAutoConfiguration
- 与 Spring Boot 2 客户端保持一致,支持 @Value 和 @ConfigurationProperties 动态刷新
This commit is contained in:
2026-03-23 21:04:15 +08:00
parent 82707de831
commit c2e599097e
38 changed files with 386 additions and 1232 deletions
@@ -1,43 +0,0 @@
package cn.odboy.demo;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
public class ConfigController {
@Value("${app.name:unknown}")
private String appName;
@Value("${app.version:unknown}")
private String appVersion;
@Value("${db.url:unknown}")
private String dbUrl;
@Value("${db.username:unknown}")
private String dbUsername;
@Value("${custom.config1:unknown}")
private String customConfig1;
@GetMapping("/")
public Map<String, Object> index() {
Map<String, Object> result = new HashMap<>();
result.put("appName", appName);
result.put("appVersion", appVersion);
result.put("dbUrl", dbUrl);
result.put("dbUsername", dbUsername);
result.put("customConfig1", customConfig1);
return result;
}
@GetMapping("/health")
public String health() {
return "OK";
}
}
@@ -1,12 +0,0 @@
package cn.odboy.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
@@ -1,2 +0,0 @@
org.springframework.boot.env.EnvironmentPostProcessor=\
cn.odboy.confcenter.springboot.KenaitoEnvironmentInitializer
@@ -1,21 +0,0 @@
# Server
server.port=8081
# Application
app.name=kenaito-conf-springboot3-client-demo
app.version=1.0.0
# Kenaito Config Center
kenaito.config.baseUrl=http://localhost:8080
kenaito.config.appName=kenaito-springboot-demo
kenaito.config.profile=daily
kenaito.config.version=latest
kenaito.config.token=
kenaito.config.sync-interval-seconds=30
# Local configs (will be overridden by remote if exists)
database.host=192.168.1.1
database.port=8888
database.name=xxxx
database.user=xxxx
database.password=xxxxxxxx