knightliao / disconf

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

在xml文件里面用${xx}的方式无法获取值 #282

Open xiaotao0511 opened 7 years ago

xiaotao0511 commented 7 years ago

按照spring-boot-demo里面的代码,在我的项目里面无法再xml里获取远程配置文件的配置项值,搞了一下午了,不知道是哪里出了错,求大神指导

xiaotao0511 commented 7 years ago

是否使用远程配置文件,true(默认)会从远程获取配置, false则直接获取本地配置

disconf.enable.remote.conf=true

配置服务器的 HOST,用逗号分隔 ,示例:127.0.0.1:8000,127.0.0.1:8000

disconf.conf_server_host=172.20.70.102:8081

版本号

disconf.version=1.0.0

项目名称

disconf.app=insight

环境

disconf.env=local

忽略的分布式配置,用空格分隔

disconf.ignore=

获取远程配置,重试时休眠时间,默认是5秒

disconf.conf_server_url_retry_sleep_seconds=5

用户定义的下载文件夹, 远程文件下载后会放在这里。注意,此文件夹必须有有权限,否则无法下载到这里

disconf.user_define_download_dir=./src/main/resources

下载的文件会被迁移到classpath根路径下,强烈建议将此选项置为 true(默认是true)

disconf.enable_local_download_dir_in_class_path=true

xiaotao0511 commented 7 years ago
<bean id="disconfMgrBean" class="com.baidu.disconf.client.DisconfMgrBean"
      destroy-method="destroy">
    <property name="scanPackage" value="com.infinitus.it.insight"/>
</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*:autoconfig.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>

<bean id="autoService" class="com.infinitus.it.insight.config.AutoService">
    <property name="auto" value="${auto}"/>
</bean>
xiaotao0511 commented 7 years ago

Could not resolve placeholder 'auto' in string value "${auto}" 一直报这个错误,服务器上绝对是有这个文件的

yungkit commented 6 years ago

感觉这个项目没人维护的。。。都用携程那个了