美文网首页
Dubbo Admin配置

Dubbo Admin配置

作者: 王兴岭 | 来源:发表于2020-06-06 17:33 被阅读0次

    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();
        }
      }
    }
    

    启动Dubbo Admin看看Provider

    image.png

    相关文章

      网友评论

          本文标题:Dubbo Admin配置

          本文链接:https://www.haomeiwen.com/subject/xkcftktx.html