java - PropertyPlaceHolderConfigurer 替代方案
问题描述
我的代码在 PropertyPlaceHolderConfigurer 中,它已被弃用。任何替代方案。代码如下 -
公共无效初始化(属性属性){
// SPECIFIC properties (database connection, handlers)
if (properties != null) {
ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] {
CONTEXT }, false);
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();--Problem
here
configurer.setProperties(properties);
context.addBeanFactoryPostProcessor(configurer);
context.refresh();
this.DefinitionDao = (DefinitionDao)
context.getBean("DefinitionDao");
this.logger = (Logger) context.getBean("Logger");
}
解决方案
如果您阅读了告诉您替换是什么的javadocs 。
已弃用。从 5.2 开始;
org.springframework.context.support.PropertySourcesPlaceholderConfigurer
通过利用Environment
和PropertySource
机制,使用更灵活的方法。
总之使用PropertySourcesPlaceholderConfigurer
.
您遇到的下一次弃用的经验法则,通常在弃用类的 java 文档中提到替换。
推荐阅读
- python - Pandas DataFrame 根据条件删除 NaN 行?
- reactjs - 使用单个 fetching reducer 时,Fetching flag 不会更新
- laravel - Laravel 队列不断生成`illuminate:queue:restart`
- typescript - 具有输入字段的动态 FormArray 已阻止输入
- telethon - MessageMediaDocument 不返回 file_id(如机器人)
- r - 错误:inDL(x, as.logical(local), as.logical(now), ...) 中“raster”的包或命名空间加载失败:
- angular - npm 安装错误 - 未检测到 Xcode 或 CLT 版本?
- flutter - Flutter Text 仅在空格处换行
- laravel - 资源路由上的可选附加参数 - laravel
- kernel-module - 从另一个内核模块访问 tty 驱动程序