没有Spring Boot的Spring Cloud Config客户端 [英] Spring Cloud Config Client Without Spring Boot

查看:84
本文介绍了没有Spring Boot的Spring Cloud Config客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经将现有的Spring Web应用程序作为WAR文件部署到Amazon Elastic Beanstalk中.当前,我们将属性文件作为http资源加载,以提供属性占位符配置解析的单一来源.我正在研究用新的Spring Cloud配置服务器替换它,以便为我们提供git版本控制等优势.

We have an existing spring web app deployed as a WAR file into Amazon Elastic Beanstalk. Currently we load properties files as http resources to give us a single source of property placeholder config resolution. Im investigating replacing this with the new spring cloud configuration server to give us the benefits of git versioning etc.

但是文档( http://cloud.spring.io/spring-cloud -config/spring-cloud-config.html )似乎仅描述了Spring Boot客户端应用程序.是否可以在现有Web应用程序中设置Spring Cloud Config Client?我是否需要手动设置Bootstrap父应用程序上下文等-是否有任何示例?我们当前的spring配置基于XML.

However the documentation (http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html) only seems to describe a Spring Boot client application. Is it possible to set up the Spring Cloud Config Client in an existing web app? Do I need to manually set up the Bootstrap parent application context etc - are there any examples of this? Our current spring configuration is XML based.

推荐答案

我有类似的要求;我有一个使用Spring XML配置定义一些bean的Web应用程序,这些属性的值存储在.property文件中.要求是在开发过程中应从硬盘加载配置,并在生产环境中从Spring Cloud Config服务器加载配置.

I have similar requirement; I have a Web Application that uses Spring XML configuration to define some beans, the value of the properties are stored in .property files. The requirement is that the configuration should be loaded from the hard disk during the development, and from a Spring Cloud Config server in the production environment.

我的想法是为PropertyPlaceholderConfigurer定义两个:第一个将用于从硬盘加载配置:

My idea is to have two definition for the PropertyPlaceholderConfigurer; the first one will be used to load the configuration from the hard disk :

        <bean id="resources" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" doc:name="Bean">
        <property name="locations">
            <list>
                <value>dcm.properties</value>
                <value>post_process.properties</value>
            </list>
        </property>
    </bean>

第二个将从Spring Config Server加载.properties:

The second one will load the .properties from the Spring Config Server :

    <bean id="resources" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" doc:name="Bean">
        <property name="locations">
            <list>
                <value>http://localhost:8888/trunk/dcm-qa.properties</value>
            </list>
        </property>
    </bean>

这篇关于没有Spring Boot的Spring Cloud Config客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆