knightliao / disconf

Distributed Configuration Management Platform(分布式配置管理平台)
http://disconf.readthedocs.io/
Apache License 2.0
5.57k stars 2.29k forks source link

Spring @Value 注解方式的配置修改后无法动态加载 #273

Open fireflyhoo opened 7 years ago

fireflyhoo commented 7 years ago

` <bean id="disconfMgrBean" class="com.baidu.disconf.client.DisconfMgrBean" destroy-method="destroy">

</bean>
<bean id="disconfMgrBean2" class="com.baidu.disconf.client.DisconfMgrBeanSecond"
      init-method="init" destroy-method="destroy">
</bean>

<!-- 使用托管方式的disconf配置(无代码侵入, 配置更改会自动reload)-->
<bean id="configproperties_disconf"
      class="com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean">
    <property name="locations">
        <list>
            <!-- 公共的  -->
            <value>classpath:/common-config.properties</value>
            <value>classpath:/dubbo-config.properties</value>
            <value>classpath:/ejob.properties</value>
            <value>classpath:/idgenerator-config.properties</value>
            <value>classpath:/mq-config.properties</value>
            <value>classpath:/redis-config.properties</value>
            <value>classpath:/redis-uc-config.properties</value>
            <value>classpath:/shiro-client-default.properties</value>

            <!-- uc 自有的 -->
            <value>classpath:/jdbc.properties</value>
            <value>classpath:/uc-config.properties</value>
        </list>
    </property>
</bean>

<bean id="propertyConfigurer"
      class="com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer">
    <property name="ignoreResourceNotFound" value="true" />
    <property name="ignoreUnresolvablePlaceholders" value="true" />
    <property name="propertiesArray">
        <list>
            <ref bean="configproperties_disconf"/>
        </list>
    </property>
</bean>`

image 类似这样的配置, 修改后不能重载

fireflyhoo commented 7 years ago

(⊙o⊙)…,没人鸟我?

fireflyhoo commented 7 years ago

@ngloom @MaGonglei @nabilzhang @markyao @knightliao

GreatGarlic commented 7 years ago

@fireflyhoo 确实不行,只能在xml中用“${xxxx}”,才会生效,在配置类中用spring的@value注解是不起作用的,如果你实在想这样用,只能手动实现reload方法在回调时拦截你要修改的字段,手动更新这个字段