PropertySourceLocator
发布日期:2021-06-30 14:53:57
浏览次数:3
分类:技术文章
本文共 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 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
路过按个爪印,很不错,赞一个!
[***.219.124.196]2024年04月21日 20时11分01秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
冷眼看小程序
2019-05-01
为什么执行 x in range(y) 如此快?
2019-05-01
看完这篇文章你还不理解 Python 装饰器,只有一种可能...
2019-05-01
Python干货:表达式 i += x 与 i = i + x 等价吗?
2019-05-01
有了这些 Chrome 插件,效率提升10倍(建议收藏)
2019-05-01
Python 编码错误的本质原因
2019-05-01
Python 开发者都会遇到的错误:UnboundLocalError
2019-05-01
用 Python 送“爱心”
2019-05-01
理解HTTPS为什么安全前,先看看这些东西
2019-05-01
代码这样写不止于优雅(Python版)
2019-05-01
只有1%的程序员搞懂过浮点数陷阱
2019-05-01
Erlang 之父 Joe Armstrong 去世
2019-05-01
一名 Google 工程师的大数据处理经验
2019-05-01
30分钟学会pyecharts数据可视化
2019-05-01
从一个骗子身上学到的
2019-05-01
关于Python爬虫,这里有一条高效的学习路径
2019-05-01
Python学习指南,看这篇清晰多了!
2019-05-01
命名难,难于上青天
2019-05-01
史上最烂项目:苦撑12年,600多万行代码...
2019-05-01
斯坦福后空翻机器人设计、代码全开源,成本降至3000美元,人人皆可DIY
2019-05-01