我正在注入带有EnvironmentPostProcessor
的属性,它们是来自另一个属性xml文件的旧版属性,
如何通过REST URL访问属性列表?
@Component
public class SpringCloudConfigRuntimeEnvironmentPostProcessor implements
EnvironmentPostProcessor {
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
LinkedHashMap<String, Object> map = new LinkedHashMap<>();
map.put("com.xyz.jdbcUrl", "x.y.z");
MapPropertySource propertySource = new MapPropertySource("defaultProperties", map);
environment.getPropertySources().addLast(propertySource);
然后我将其添加到spring.factories
org.springframework.boot.env.EnvironmentPostProcessor=com.xyz.configservice.config.SpringCloudConfigRuntimeEnvironmentPostProcessor
当我打印环境时,我确实看到它们正在加载
在application.yml
server:
port: 8888
spring:
application:
name: config-service
我找不到正确的语法来获取我加载的那些属性,这是我尝试过的许多属性中的几个: http://x.x.x.x:8888/config-service/defaultProperties-default.properties http://x.x.x.x:8888/defaultProperties-default.properties