Dubbo 2.7 Admin配置说明
application.properties
配置项说明
- admin.config-center
- 推荐使用,配置中心地址,比如
admin.config-center="zookeeper://127.0.0.1:2181"
- 需要在配置中心中配置注册中心和元数据中心地址配置格式如下:
- zookeeper
-
path:
/dubbo/config/dubbo/dubbo.properties
-
content:
dubbo.registry.address=zookeeper://127.0.0.1:2181 dubbo.metadata-report.address=zookeeper://127.0.0.1:2181
-
- 推荐使用,配置中心地址,比如
代码
package org.apache.dubbo.admin.listener;
import org.apache.curator.framework.CuratorFramework;
import org.apache.dubbo.admin.registry.config.impl.ZookeeperConfiguration;
import org.apache.dubbo.common.URL;
public class Creator {
public static void main(String[] args) {
ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration();
URL url = URL.valueOf("zookeeper://127.0.0.1:2181");
zookeeperConfiguration.setUrl(url);
zookeeperConfiguration.init();
CuratorFramework zkClient = zookeeperConfiguration.getZkClient();
try {
if (zkClient.checkExists().forPath("/dubbo/config/dubbo/dubbo.properties") == null) {
zkClient.create().creatingParentsIfNeeded().forPath("/dubbo/config/dubbo/dubbo.properties");
}
zkClient.setData().forPath("/dubbo/config/dubbo/dubbo.properties",
("dubbo.registry.address=zookeeper://127.0.0.1:2181\n" +
"dubbo.metadata-report.address=zookeeper://127.0.0.1:2181").getBytes());
} catch (Exception e) {
e.printStackTrace();
}
}
}
网友评论