java - 从 Spring 重新加载属性
问题描述
xml里面
<bean id="properties" class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer">
<property name="location">
<value>WEB-INF/classes/applicationContext.properties</value>
<value>WEB-INF/classes/myProperties.properties</value>
</property>
</bean>
更新文件时如何刷新所有 bean 的属性?
解决方案
例如,刷新 bean 的最佳方法是添加此范围“@RefreshScope”
只需在可刷新的 bean 上添加 @RefreshScope 注释,在主/配置上添加 @EnableConfigServer 即可。
如果您想了解更多配置https://projects.spring.io/spring-cloud/spring-cloud.html
问候!
推荐阅读
- if-statement - 如果没有值,则让 Iferror 和 Googlefinance 打印“空白”单元格
- c# - Blazor - 获取由父级设置的对象
- python - 从 csv 数据创建对象
- odoo-15 - 如何在 odoo15 中添加模块
- reactjs - 当我通过 fetch 和 componentDidMount 传递值时,该值没有显示
- html - 需要帮助在文本部分做出本机反应
- node.js - Webhint 错误:AnalyzerError: EBADF: bad file descriptor, lstat '/dev/fd/10'
- swift - PDFView (UIViewer) [Swift, iOS 15, PDFKit] 中无法识别屏幕边缘手势
- javascript - D3 Gauge Chart - 如何为四个部分和旋钮添加图例而不是针?
- html - 在下一行有相同的填充