PropertySourceLocator
发布日期:2021-06-30 14:53:57 浏览次数:2 分类:技术文章

本文共 1528 字,大约阅读时间需要 5 分钟。

TestPropertySourceLocator

import org.springframework.cloud.bootstrap.config.PropertySourceLocator;import org.springframework.core.env.CompositePropertySource;import org.springframework.core.env.Environment;import org.springframework.core.env.PropertySource;/** * @author jerryjin  */public class TestPropertySourceLocator implements PropertySourceLocator {
private static final String INSPECTION_PROPERTY_SOURCE_NAME ="BCZN_INSPECTION"; @Override public PropertySource
locate(Environment environment) {
CompositePropertySource composite = new CompositePropertySource(INSPECTION_PROPERTY_SOURCE_NAME); System.out.println("==========================================================="); System.out.println(environment.resolveRequiredPlaceholders("${hero.name:}")); System.out.println("==========================================================="); // composite. return composite; }}

TestSourceLocatorConfig

import com.jerry.inspection.listener.TestPropertySourceLocator;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;/** * @author jerryjin */@Configurationpublic class TestSourceLocatorConfig {
@Bean public TestPropertySourceLocator inspectionPropertySourceLocator(){
return new TestPropertySourceLocator(); } }

src/main/resources/META-INF/spring.factories

org.springframework.cloud.bootstrap.BootstrapConfiguration=\com.jerry.inspection.config.TestSourceLocatorConfig

转载地址:https://jerryjin.blog.csdn.net/article/details/114323239 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Linux 安装与配置 RabbitMQ
下一篇:Win10 休眠按钮不见了

发表评论

最新留言

表示我来过!
[***.240.166.169]2024年04月25日 16时15分51秒