I'm working with a SpringBoot app and try to update new value from consul server when the config is changed. Follow the document from Spring Cloud but can not update new value without restarting the spring boot application.
Here is the bootstrap.yml
config file:
spring:
application:
name: api-app
cloud:
consul:
discovery:
enabled: true
register: false
host: ${CONSUL_IP:192.168.1.10}
port: ${CONSUL_PORT:8500}
config:
acl-token: ${CONSUL_ACL_TOKEN:xxx-xxx-xxx-xxx}
enabled: true
defaultContext: configuration
format: YAML
watch:
enabled: true
application.java
@SpringBootApplication
@EnableConfigurationProperties(value= {ConsulValueProperties.class})
@EnableJpaRepositories
@EnableCaching
@EnableDiscoveryClient
public class SpringApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
setRegisterErrorPageFilter(false);
return application.sources(SpringApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(SpringApplication.class, args);
}
}
I've tried this document and seem application auto update Spring Cloud Consul: 3.5. Consul Catalog Watch
So, will spring boot automatically update the value when consul changes without restarting the spring boot application? If yes, how to config that or document? Thank you for reading and support!!!