你好!
我有针对Zookeeper的带有Spring Cloud Starter自动配置的Spring Boot应用程序。
在Zookeper节点中进行某些更改时,我遇到了一些刷新上下文的问题。
这是我的pom.xml
:
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
<camel.version>2.23.1</camel.version>
<spring-boot.version>2.1.2.RELEASE</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-zookeeper-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-config</artifactId>
</dependency>
我有两个问题: 1.例如,当我配置bootstrap.yml时:
cloud:
zookeeper:
connect-string: localhost:2181
config:
enable: true
root: config
defaultContext: apps
profileSeparator: '::'
application:
name: my_application
然后在propertySourceContext
中创建了两个ZookeeperPropertySourceLocator
:“ config / apps”和“ config / my_application”
对我而言,application.name
用于构建到动物派遣者节点的路径并不明显。
为什么我同时需要defaultContext
和application.name
来构建路径?我真的很想明白)
当我使用同名的defaultContext
和application.name
时,
那么会导致创建两个两个propertySourceContext
,并且所有RefreshScope
bean刷新两次,这是正常的吗?)
@EventListener(RefreshScopeRefreshedEvent.class)
(用于刷新方法)来捕获刷新我的ZooKeeper,但是我对ZooKeeper的任何更改都称为此方法:(
我可以在zookeeper中的某个Node上订阅并仅刷新某些bean吗?
我在public boolean refresh(String name)
中看到了名为RefreshScope.class
的方法,该如何调用呢?谢谢! 附言对不起,我最好的英语!