-
spring-boot 配置文件 https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config.files
- "spring.config.name" 在代码里搜索找到对应的类
-
spring-cloud 配置文件 https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#customizing-bootstrap-properties
- "spring.cloud.bootstrap.name" 在代码里搜索找到对应的类
- 不要用 spring 运行完然后注入配置的方式
StandardEnvironment environment = new StandardEnvironment();
// begin: application.* files
// 最好用 version 2.3 来, 2.4 被标记 Deprecated
new ConfigFileApplicationListener().postProcessEnvironment(environment, application);
// end: application.* files
// begin: bootstrap.* files
// TODO 感觉和 org.springframework.cloud.bootstrap.BootstrapApplicationListener 有关,但我不会了
// end: bootstrap.* files
// 然后就能读取配置了
// environment.getProperty(