2015-12-04 37 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

相關問題