2

Is it possible to refresh property(api-url) through POST rest api /refresh call using @RefreshScope without having setup of spring cloud config server and spring cloud config client setup.

for.e.g Consumer.java

@Service
public class Consumer {

@value(${api-url})
private String apiUrl;

api-url is getting read from application.yml now. I want to change the api-url at runtime without restarting server.

Is it possible in spring boot?

user2057006
  • 617
  • 4
  • 15
  • 28

1 Answers1

0

Yes, just include spring cloud starter

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.2.RELEASE</version>
</parent>
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Dalston.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter</artifactId>
    </dependency>
</dependencies>
spencergibb
  • 24,471
  • 6
  • 69
  • 75
  • It works for property but if i change spring.active.profile in application.yml, the required property value is not getting loaded from spring.active.profile. I will post new question related to that. – user2057006 May 05 '17 at 10:18