簡體   English   中英

沒有Spring Cloud Config Server的RefreshScope運行時配置

[英]RefreshScope Runtime Configuration Without Spring Cloud Config Server

是否可以使用@RefreshScope通過POST rest api / refresh調用刷新屬性(api-url),而無需設置spring cloud配置服務器和spring cloud配置客戶端設置。

for.eg Consumer.java

@Service
public class Consumer {

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

現在正在從application.yml讀取api-url。 我想在運行時更改api-url而無需重新啟動服務器。

春季靴子有可能嗎?

是的,只包括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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM