Open Sam0913 opened 2 years ago
Spring Boot version?
run
mvn dependency:tree > tree.log
get it.
Spring Boot version?
run
mvn dependency:tree > tree.log
get it.
2.1.5.RELEASE
Spring Boot version?
run
mvn dependency:tree > tree.log
get it.
@RefreshScope 如果使用这种方式虽然可以动态更新了,但是会导致eureka 注册当前服务进行先down 在 up操作。
You could refresh the specific bean with the bean name, e.g. https://github.com/apolloconfig/apollo/blob/96ee53a2c98da763ef0e7557af33c03a8d2ae297/apollo-demo/src/main/java/com/ctrip/framework/apollo/demo/spring/springBootDemo/refresh/SpringBootApolloRefreshConfig.java#L47-L53
BTW, I verified EnvironmentChangeEvent also works in spring boot 2.4.12 and spring cloud 2020.0.4. If it doesn't work for your scenario, please take a look at your ConfigurationProperties setup and make sure it is not annotated with RefreshScope
.
BTW, I verified EnvironmentChangeEvent also works in spring boot 2.4.12 and spring cloud 2020.0.4. If it doesn't work for your scenario, please take a look at your ConfigurationProperties setup and make sure it is not annotated with
RefreshScope
.
恩,是我只写取application错误了,请问@RefreshScope 会导致服务重启的问题您遇过吗?
恩,是我只写取application错误了,请问@RefreshScope 会导致服务重启的问题您遇过吗?
@Sam0913 You need to refresh a specific bean instead of refresh all. But I think even refresh all will only trigger eureka to unregister and register itself but won't restart the service.
` @Slf4j @Component public class ApolloConfig implements ApplicationContextAware {
} `
这边能取到最新配置,但是使用@ConfigurationProperties(prefix = "spring.datasource")的配置还是久的值