2015-12-04 38 views
0

为了更好地反映我的问题,我稍微修改了我的原始问题。我有一个非Spring Boot应用程序,我希望与Spring Cloud Config Server一起工作。我在网上搜索并尝试了很多东西,但似乎我的问题的关键是服务器只能在Spring Boot环境中使用。虽然ActiveMQ已经是一个Spring应用程序,但将它转换为Spring Boot应用程序似乎并不重要。获取非Spring Boot程序(如ActiveMQ)与Spring Cloud Config配合使用

我想要一个从Spring Cloud Config配置的ActiveMQ Broker。我在application.properties中的本地设置应该被来自服务器的设置取代。这适用于我工作的其他服务器,现在我需要它为我的Broker Filter插件工作。

我增加了以下内容activemq.xml中:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="locations"> 
     <list> 
      <value>classpath:application.properties</value> 
      <value>file:${activemq.conf}/credentials.properties</value> 
     </list> 
    </property> 
</bean> 

NOTE: Several base packages omitted here but are similar to: 
<context:component-scan base-package="org.springframework.cloud.bootstrap"/> 

<!-- enables annotation based configuration --> 
<context:annotation-config /> 

这样做我能得到各种@Value注解与设置,从我application.properties来,但整个Spring Cloud Config Server事情似乎不能代替工作后我的本地application.properties文件设置。我工作的其他Spring Boot应用程序这样做我知道服务器是好的。

我已经添加了以下jar添加到Apache的ActiveMQ的-5.12.0 \ LIB \ extra目录:

spring-aop-4.1.8.RELEASE.jar 
spring-beans-4.1.8.RELEASE.jar 
spring-boot-1.2.7.RELEASE.jar 
spring-boot-actuator-1.2.7.RELEASE.jar 
spring-boot-autoconfigure-1.2.7.RELEASE.jar 
spring-boot-starter-1.2.7.RELEASE.jar 
spring-boot-starter-actuator-1.2.7.RELEASE.jar 
spring-boot-starter-data-mongodb-1.2.7.RELEASE.jar 
spring-boot-starter-logging-1.2.7.RELEASE.jar 
spring-cloud-commons-1.0.1.RELEASE.jar 
spring-cloud-config-client-1.0.1.RELEASE.jar 
spring-cloud-context-1.0.1.RELEASE.jar 
spring-cloud-starter-1.0.1.RELEASE.jar 
spring-cloud-starter-config-1.0.1.RELEASE.jar 
spring-context-4.1.8.RELEASE.jar 
spring-context-support-4.1.8.RELEASE.jar 
spring-core-4.1.8.RELEASE.jar 
spring-data-commons-1.11.0.RELEASE.jar 
spring-data-mongodb-1.8.0.RELEASE.jar 
spring-expression-4.1.8.RELEASE.jar 
spring-jms-4.1.8.RELEASE.jar 
spring-security-crypto-3.2.8.RELEASE.jar 
spring-test-4.1.8.RELEASE.jar 
spring-tx-4.1.8.RELEASE.jar 
spring-web-4.1.8.RELEASE.jar 
+0

为什么你'PropertyPlaceholderConfigurer'和'PropertySourcesPlaceholderConfigurer'?你为什么在两者都有'application.properties'? – jny

+0

拼命地试图让这个工作和重叠的想法。我可能只需要一个,在清理过程中可能会删除一个。关于如何获得非Spring Boot程序,就像我的情况一样,要使用配置服务器,你有没有任何输入? – redboy

+0

您是否仅使用PropertySourcesPlaceholderConfigurer进行了尝试?这是从外部属性文件中读取的文件 – jny

回答

0

refreshendpoint当调用构造函数不一定初始化。您需要添加与@PostConstruct的方法的注释(或实现InitializingBean和实施afterPropertiesSet法)中,你将执行refreshendpoint.refresh();,e.g:

@PostConstruct 
void init() { 
    refreshendpoint.refresh(); 
} 
+0

正确。我现在意识到那个测试的愚蠢只是为了看它是否被加载。替换application.properties是我最关心的问题。我将编辑我的原始文章以省略问题的这一部分。虽然我的主要问题仍然没有答案。 – redboy

相关问题