Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Cloud Config Server without Spring Boot

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??
like image 463
Misagh Moayyed Avatar asked Feb 23 '16 08:02

Misagh Moayyed


People also ask

Can we use spring cloud without spring boot?

We have implemented his proposed solution in production and it is working as expected. Our newer apps are being written using Boot, while our legacy apps use Spring, but not boot. We were able to use Spring Cloud Config to create a property service that serves properties for both.

Which of the following is required to enable the cloud config server?

Creating Spring Cloud Configuration Server Gradle users can add the below dependency in your build. gradle file. Now, add the @EnableConfigServer annotation in your main Spring Boot application class file. The @EnableConfigServer annotation makes your Spring Boot application act as a Configuration Server.

Why do we need spring cloud config server?

Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments.


1 Answers

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.

like image 137
Amit Goldstein Avatar answered Oct 19 '22 17:10

Amit Goldstein