I am not able to read child nodes of an application by using Spring Cloud Zookeeper configuration.
For simplicity, lets assume, i have named it as Myapplication, and the same name node i have created in Zookeeper under config (/config/Myapplication). I have created one property inside the node such as (/config/Myapplication/sample 1). So "sample" property i am able to access my application.
But Suppose if i have one child node under Myapplication (/config/Myapplication/Configuration config). Now, i need to access "config" property under the Configuration node thats not happening.
I tried accessing by below code in my application, But no luck :-
@Value("${Configuration/config: Default Child Node config}")
private String config;
Please Suggest some way to move forward from here.
@Value("${Configuration.config: 默认子节点配置}") 私有字符串配置;
in short, if you define node like this:
/config/<Your-App-Name>/consumerId 12345
you should to be able to access it like:
@Value(${consumerId})
private String consumeId
Note.- you can only define your variables as following:
/config/<Your-App-Name>/youVar1 val1
/config/<Your-App-Name>/youVar2 val2 ...etc
nodes defined as child of /config/ can be accessed easily by springboot.
more technical details here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.