Spring Cloud Config Server without Spring Boot

对着背影说爱祢 提交于 2019-12-23 09:04:11

问题


I have looked at spring-cloud-config client without Spring Boot and many others and have not found a convincing answer. So here it goes again:

Question: Is it possible, in a Spring app, to use Spring Cloud Config server/client without the automagic configuration of Spring Boot? Is using Spring Boot a requirement for using these frameworks?

If it is:

  1. Is there any documentation that clearly describes what needs to be done in order to enable Spring Cloud Config server/client without Spring Boot?
  2. Is there any sample project that clearly describes what needs to be done in order to enable Spring Cloud Config server/client without Spring Boot??

回答1:


I'm not aware of documentation or a sample project. However we are doing it in our projects.

You just need to include the configuration server URI as a property source, assuming you are using PropertySourcesPlaceholderConfigurer:

<bean class="org.springframework.context.support.PropertySourcesPlaceholderConfigurer" id="propertyPlaceholder">
    <property name="locations">
        <list>
            <value>http://your-config-server.com:8888/application-${spring.profiles.active}.properties</value>
        </list>
    </property>
    <property name="ignoreUnresolvablePlaceholders" value="false"/>
</bean>

You have to make sure to pass -Dspring.profiles.active=current_profile to the java command line, like you probably would have done with boot.



来源:https://stackoverflow.com/questions/35572457/spring-cloud-config-server-without-spring-boot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!