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