我稍微修改了原来的问题,以便更好地反映我的问题 . 我有一个非Spring Boot应用程序,我希望与Spring Cloud Config Server一起使用 . 我在网上搜索并尝试了很多东西,但似乎问题的关键在于服务器只能在Spring Boot上下文中运行 . 尽管ActiveMQ已经是Spring应用程序,但将它转换为Spring Boot应用程序似乎并非易事 .
我想要一个从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
1 回答
调用构造函数时,不一定要初始化
refreshendpoint
. 您需要使用@PostConstruct
(或实现InitializingBean
并实现afterPropertiesSet
方法)添加方法注释,您将在其中执行refreshendpoint.refresh();
,例如: