• dubbo Main独立运行,脱离web容器


    public class App 
    {
        public static void main( String[] args )
        {
            System.out.println( "dubbo start!" );
            com.alibaba.dubbo.container.Main.main(args);
        }
    }

    如果是dubbo service层,直接加一个app main启动类,里面加入如上代码

    在加一个resource资源目录,设置成资源文件夹,里面加入 dubbo.properties,application-config.xml[这个就是spring应用配置文件,里面包含dubbo-provider配置内容]

    加入如下内容

    #dubbo.container=log4j,spring
    #dubbo.registry.address=zookeeper://127.0.0.1:2181
    #dubbo.protocol.name=dubbo
    #dubbo.service.loadbalance=roundrobin
    dubbo.spring.config=classpath:application-config.xml  
    dubbo.log4j.level=DEBUG  

    编译启动

    017-11-07 15:18:03 [INFO] - Waiting for keeper state SyncConnected
    2017-11-07 15:18:03 [INFO] - Opening socket connection to server 127.0.0.1/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
    2017-11-07 15:18:03 [INFO] - Socket connection established to 127.0.0.1/127.0.0.1:2181, initiating session
    2017-11-07 15:18:03 [DEBUG] - Session establishment request sent on 127.0.0.1/127.0.0.1:2181
    2017-11-07 15:18:03 [TRACE] - readConnectResult 37 0x[0,0,0,0,0,0,ffffff9c,40,1,5f,ffffff95,19,5a,ffffffc6,0,1,0,0,0,10,ffffffeb,ffffffe5,ffffffe3,fffffffd,25,5d,fffffff7,fffffffb,6b,2,1,ffffffe5,ffffffaa,5a,fffffff9,5f,0,]
    2017-11-07 15:18:03 [INFO] - Session establishment complete on server 127.0.0.1/127.0.0.1:2181, sessionid = 0x15f95195ac60001, negotiated timeout = 40000
    2017-11-07 15:18:03 [DEBUG] - Received event: WatchedEvent state:SyncConnected type:None path:null
    2017-11-07 15:18:03 [INFO] - zookeeper state changed (SyncConnected)
    2017-11-07 15:18:03 [DEBUG] - Leaving process event
    2017-11-07 15:18:03 [DEBUG] - State is SyncConnected
    2017-11-07 15:18:03 [DEBUG] - Reading reply sessionid:0x15f95195ac60001, packet:: clientPath:null serverPath:null finished:false header:: 1,1  replyHeader:: 1,444,-110  request:: '/dubbo,,v{s{31,s{'world,'anyone}}},0  response::  
    2017-11-07 15:18:03 [DEBUG] - Reading reply sessionid:0x15f95195ac60001, packet:: clientPath:null serverPath:null finished:false header:: 2,1  replyHeader:: 2,445,-110  request:: '/dubbo/com.xxxxx.cardbag.gateway.CardBagInterface,,v{s{31,s{'world,'anyone}}},0  response::  
    2017-11-07 15:18:03 [DEBUG] - Reading reply sessionid:0x15f95195ac60001, packet:: clientPath:null serverPath:null finished:false header:: 3,1  replyHeader:: 3,446,-110  request:: '/dubbo/com.xxxxx.cardbag.gateway.CardBagInterface/providers,,v{s{31,s{'world,'anyone}}},0  response::  
    2017-11-07 15:18:03 [DEBUG] - Reading reply sessionid:0x15f95195ac60001, packet:: clientPath:null serverPath:null finished:false header:: 4,1  replyHeader:: 4,447,0  request:: '/dubbo/com.xxxxx.cardbag.gateway.CardBagInterface/providers/dubbo%253A%252F%252F192.168.2.112%253A20880%252Fcom.xxxxx.cardbag.gateway.CardBagInterface%253Fanyhost%253Dtrue%2526application%253Drpcdevelop_service%2526dubbo%253D2.8.4%2526generic%253Dfalse%2526interface%253Dcom.toolmall.cardbag.gateway.CardBagInterface%2526methods%253DmerchantRecharge%252CpayMoneyFromCard%252CgetCardStatus%252CgetAuthorizeToken%252CgetCard%252CgetTotalCardInfo%252CexchangeCardUser%2526pid%253D25520%2526side%253Dprovider%2526timeout%253D12000%2526timestamp%253D1510039083273,,v{s{31,s{'world,'anyone}}},1  response:: '/dubbo/com.toolmall.cardbag.gateway.CardBagInterface/providers/dubbo%253A%252F%252F192.168.2.112%253A20880%252Fcom.toolmall.cardbag.gateway.CardBagInterface%253Fanyhost%253Dtrue%2526application%253Drpcdevelop_service%2526dubbo%253D2.8.4%2526generic%253Dfalse%2526interface%253Dcom.toolmall.cardbag.gateway.CardBagInterface%2526methods%253DmerchantRecharge%252CpayMoneyFromCard%252CgetCardStatus%252CgetAuthorizeToken%252CgetCard%252CgetTotalCardInfo%252CexchangeCardUser%2526pid%253D25520%2526side%253Dprovider%2526timeout%253D12000%2526timestamp%253D1510039083273 
    2017-11-07 15:18:03 [DEBUG] - Reading reply sessionid:0x15f95195ac60001, packet:: clientPath:null serverPath:null finished:false header:: 5,1  replyHeader:: 5,448,-110  request:: '/dubbo,,v{s{31,s{'world,'anyone}}},0  response::  
    2017-11-07 15:18:03 [DEBUG] - Reading reply sessionid:0x15f95195ac60001, packet:: clientPath:null serverPath:null finished:false header:: 6,1  replyHeader:: 6,449,-110  request:: '/dubbo/com.xxxxx.cardbag.gateway.CardBagInterface,,v{s{31,s{'world,'anyone}}},0  response::  
    2017-11-07 15:18:03 [DEBUG] - Reading reply sessionid:0x15f95195ac60001, packet:: clientPath:null serverPath:null finished:false header:: 7,1  replyHeader:: 7,450,-110  request:: '/dubbo/com.xxxxx.cardbag.gateway.CardBagInterface/configurators,,v{s{31,s{'world,'anyone}}},0  response::  
    2017-11-07 15:18:03 [DEBUG] - Reading reply sessionid:0x15f95195ac60001, packet:: clientPath:null serverPath:null finished:false header:: 8,3  replyHeader:: 8,450,0  request:: '/dubbo/com.xxxxx.cardbag.gateway.CardBagInterface/configurators,T  response:: s{442,442,1510038204779,1510038204779,0,0,0,0,0,0,442} 
    2017-11-07 15:18:03 [DEBUG] - Reading reply sessionid:0x15f95195ac60001, packet:: clientPath:null serverPath:null finished:false header:: 9,8  replyHeader:: 9,450,0  request:: '/dubbo/com.xxxxx.cardbag.gateway.CardBagInterface/configurators,T  response:: v{} 
    [2017-11-07 15:18:03] Dubbo service server started!

    有问题欢迎斧正

  • 相关阅读:
    AcWing 2476. 树套树(线段树套splay)
    LeetCode 1191 K 次串联后最大子数组之和
    LeetCode 668 乘法表中第k小的数
    Java003-String字符串
    云原生CD工具spinnaker部署(容器化灰度发布)
    刷题日记
    8.22 校内模拟赛 题解报告
    关于 CDQ分治(复习)
    解题营_数论
    解题营_动规
  • 原文地址:https://www.cnblogs.com/fangyuan303687320/p/7799165.html
Copyright © 2020-2023  润新知