是否可以使用@RefreshScope通过POST rest api / refresh调用刷新属性(api-url),而无需设置spring cloud配置服务器和spring cloud config客户端设置。
for.e.g Consumer.java
@Service
public class Consumer {
@value(${api-url})
private String apiUrl;
现在正在从application.yml读取api-url。我想在运行时更改api-url而不重新启动服务器。
春季靴子有可能吗?
答案 0 :(得分:0)
是的,只包括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>