【发布时间】:2015-12-08 02:40:49
【问题描述】:
我稍微修改了我原来的问题,以更好地反映我的问题。我有一个非 Spring Boot 应用程序,我想与 Spring Cloud Config Server 一起使用。我在网上搜索并尝试了很多东西,但似乎我的问题的症结在于服务器只能在 Spring Boot 上下文中工作。尽管 ActiveMQ 已经是一个 Spring 应用程序,但将其转换为 Spring Boot 应用程序似乎并非易事。
我想要一个从 Spring Cloud Config 配置的 ActiveMQ Broker。 application.properties 中的本地设置应替换为来自服务器的设置。这适用于我工作的其他服务器,现在我需要它为我的代理过滤器插件工作。
我在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
【问题讨论】:
-
为什么会有
PropertyPlaceholderConfigurer和PropertySourcesPlaceholderConfigurer?为什么两个都有application.properties? -
拼命地试图让它发挥作用并且想法重叠。我可能只需要一个,并且可能会在清理过程中移除一个。关于获得一个非 Spring Boot 程序,就像我的情况一样,ActiveMQ 与配置服务器一起工作,你有什么意见吗?
-
您是否尝试过仅使用 PropertySourcesPlaceholderConfigurer?这是从外部属性文件中读取的文件
-
@jny - 是的。我现在正在尝试使用 org.springframework.beans.factory.config.PropertyPlaceholderConfigurer
-
这个问题有更新吗?
标签: spring spring-boot activemq