首页 > 解决方案 > 从 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 的属性?

标签: javaspring

解决方案


例如,刷新 bean 的最佳方法是添加此范围“@RefreshScope”

只需在可刷新的 bean 上添加 @RefreshScope 注释,在主/配置上添加 @EnableConfigServer 即可。

如果您想了解更多配置https://projects.spring.io/spring-cloud/spring-cloud.html

问候!


推荐阅读