feat: 初始化配置中心项目
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
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";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
org.springframework.boot.env.EnvironmentPostProcessor=\
|
||||
cn.odboy.confcenter.springboot.KenaitoEnvironmentInitializer
|
||||
@@ -0,0 +1,19 @@
|
||||
# Server
|
||||
server.port=8081
|
||||
|
||||
# Application
|
||||
app.name=kenaito-conf-springboot2-client-demo
|
||||
app.version=1.0.0
|
||||
|
||||
# Kenaito Config Center
|
||||
kenaito.config.baseUrl=http://localhost:8080
|
||||
kenaito.config.appName=demo
|
||||
kenaito.config.profile=dev
|
||||
kenaito.config.version=latest
|
||||
kenaito.config.token=
|
||||
kenaito.config.sync-interval-seconds=30
|
||||
|
||||
# Local configs (will be overridden by remote if exists)
|
||||
db.url=jdbc:mysql://localhost:3306/local_db
|
||||
db.username=local_user
|
||||
custom.config1=local_value
|
||||
Reference in New Issue
Block a user