• dubbo环境搭建与tomcat集成、DEMO示例、常见问题(最完整版本、带管理控制台、监控中心、zookeeper)


      注1:最新的dubbo 2.7变化参见http://dubbo.apache.org/zh-cn/docs/user/versions/version-270.html

      注2:dubbo 2.7的三大核心变化,以及dubbo各个分支的维护情况参见:https://blog.csdn.net/javahongxi/article/details/88732081(其中2.7的新特性,我们在2.5.x的版本上通过fork源码进行了解决)

      以windows为例,linux基本相同,开发环境一般linux,个人环境一般windows(如果不开额外vm的话)。

      示例以dubbo官方自带demo为例子,进行整合和稍加修改测试。

      dubbo面试题

    0、dubbox是dubbo的当当fork版本,特性上最主要是集成了REST。就核心功能而言,dubbo和大部分其他rpc框架比如spring cloud类似,由客户端、服务端、服务注册与发现中心、监控中心以及管理中心组成。如下:

    1、安装zookeeper,从https://zookeeper.apache.org/releases.html下载3.4.x最新稳定版,解压后,执行bin/zkServer.cmd启动zookeeper服务。如下:

    2、从dubbox git clone或者下载2.8.4版本,执行mvn install -Dmaven.test.skip=true生成各jar;

    3、从http://git.oschina.net/handu/dubbo-monitor git clone,执行maven clean package创建监控war,并创建mysql表,并在application.properties设置登录用户名、密码。

    4、下载并安装mysql。

    5、maven编译生成dubbo管理控制台,,并在WEB-INF/dubbo.properties里面设置登录用户名、密码;

    6、下载tomcat,将dubbo-admin.war,dubbo-monitor.war拷贝到tomcat webapps目录下,启动。如下:

     

    6、上述步骤执行完成后,dubbox的基础环境都完成了。剩下就是dubbox开发时集成的问题。

    7、在现实中,大部分分布式系统的某个部件一般同时承担服务消费端和生产端的角色。很少仅仅承担客户端或者服务端的场景。所以他俩基本上是一起出现的。

     dubbo默认提供了5个容器(有基于spring xml的,spring annotation config的,也有支持http的jetty,log4j和logback是为了启动多进程时日志不会互串):

    默认是基于spring xml的容器。其启动类com.alibaba.dubbo.container.spring.SpringContainer.start()会自动加载classpath*:META-INF/spring/*.xml下的配置文件。所以,就不提供REST的应用而言,采用这种方式也是可以的。以前公司采用自行开发的rpc框架时,就是通过这种方式运行(采用java service wrapper封装),不使用web容器。

    在我们现在工作中,除了需要暴露tcp服务外,还需要对外提供http服务,这意味着需要使用到servlet容器。而根据实际经验,jetty在稳定性上并不如tomcat,故我们需要考虑是使用内嵌的tomcat还是将dubbo服务嵌入standalone的tomcat容器。个人不喜欢在应用中内嵌容器,就像有了房子再选择装修,而不是定了装修再去选房一样。

    8、使用外部tomcat(官方叫servlet派发请求,其实就是采用spring dispatchservlet作为前端控制器,也是推荐的方式,不过默认的是嵌入的jetty,当当增强支持嵌入tomcat)。以dubbo自带的dubbo-demodubbo-demo-provider为例子,dubbo REST的开发可参考http://dangdangdotcom.github.io/dubbox/rest.html,跟正常的REST服务开发一样,只不过采用的是jboss resteasy而非spring mvc,两者的差别可参考http://www.cnblogs.com/zhjh256/p/6883417.html,同时加dubbo相关的注解一起加上去。实际上dubbo-demo-provider自带了外部容器的配置,只是默认采用内置的,如下:

        <!-- use embed tomcat server
        <dubbo:protocol name="rest" port="8888" threads="500" contextpath="services" server="tomcat" accepts="500"
                        extension="com.alibaba.dubbo.demo.extension.TraceInterceptor,
                        com.alibaba.dubbo.demo.extension.TraceFilter,
                        com.alibaba.dubbo.demo.extension.ClientTraceFilter,
                        com.alibaba.dubbo.demo.extension.DynamicTraceBinding,
                        com.alibaba.dubbo.demo.extension.CustomExceptionMapper,
                        com.alibaba.dubbo.rpc.protocol.rest.support.LoggingFilter"/>
         -->
        <!-- use the external tomcat or other server with the servlet approach; the port and contextpath must be exactly the same as those in external server -->
        <dubbo:protocol name="rest" port="8888" contextpath="services" server="servlet"/>
        
        <!-- disable other protocol
        <dubbo:protocol name="http" port="8889"/>
        <dubbo:protocol name="hessian" port="8890"/>
        <dubbo:protocol name="webservice" port="8892"/>
        -->

    使用外部tomcat容器有一个要求:

    • 协议的端口<dubbo:protocol port="8080" />必须与servlet容器的端口相同,
    • 协议的上下文路径<dubbo:protocol contextpath="foo" />必须与servlet应用的上下文路径相同。

    对于上述配置,对应的web.xml配置如下:

        <servlet>
            <servlet-name>dispatcher</servlet-name>
            <servlet-class>com.alibaba.dubbo.remoting.http.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>1</load-on-startup>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>/services/*</url-pattern>
        </servlet-mapping>
    这个DispatcherServlet和spring mvc的dispatcherservlet,也是继承于HttpServlet,只不过在职责上相对于spring mvc轻量很多,比如并不需要提供mvc的特性。

    eclipse中启动tomcat:

    9、REST访问。

    10、dubbo rpc客户端访问。

    所以,可以将demo-provider.xml作为一个样板进行修改或者合并到现有工程。

    11、可选依赖剔除、三方库版本升级:

    在我们的环境中,仅使用REST和dubbo,使用独立tomcat启用,所以,可以剔除httpclient(thrift使用),cxf、mina,jetty,kyto,web service,tomcat,redis,multicast,rmi,thrift等。因为使用了maven-shade-plugin jar合并插件,所以需要除了dependency移除外,对应maven-shade-plugin下要一并注释。进行这样调整后,生成的dubbo.jar比原来少了200K,额外的jar包依赖也少了不少。

    同时,dubbo 2.2.0开始,zookeeper客户端从官方自带客户端调整为了zkclient(https://github.com/sgroschupf/zkclient)并设为默认,2.3.0开始引入

    Curator,netflix开源的一个zookeeper客户端。可通过<dubbo:registry address="zookeeper://127.0.0.1:2181" client="curator"/>选择zookeeper客户端实现。

    同时相关jar版本调整如下:

    jackson: 2.8.8

    resteasy: 3.0.23.Final

    spring: 4.3.7.RELEASE

    slf4j:1.7.25

    fastjson:1.2.31

    curator:2.8.0

    调整后dubbo/pom.xml如下:

    <!--
     - Copyright 1999-2011 Alibaba Group.
     -  
     - Licensed under the Apache License, Version 2.0 (the "License");
     - you may not use this file except in compliance with the License.
     - You may obtain a copy of the License at
     -  
     -      http://www.apache.org/licenses/LICENSE-2.0
     -  
     - Unless required by applicable law or agreed to in writing, software
     - distributed under the License is distributed on an "AS IS" BASIS,
     - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     - See the License for the specific language governing permissions and
     - limitations under the License.
    -->
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo-parent</artifactId>
            <version>2.8.4</version>
        </parent>
        <artifactId>dubbo</artifactId>
        <packaging>jar</packaging>
        <name>${project.artifactId}</name>
        <description>The all in one project of dubbo</description>
        <properties>
            <skip_maven_deploy>false</skip_maven_deploy>
        </properties>
        <dependencies>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-config-api</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-config-spring</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-remoting-netty</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <!-- 
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-remoting-mina</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.mina</groupId>
                        <artifactId>mina-core</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-remoting-grizzly</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.glassfish.grizzly</groupId>
                        <artifactId>grizzly-core</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-remoting-p2p</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
             -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-remoting-http</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.httpcomponents</groupId>
                        <artifactId>httpclient</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.tomcat.embed</groupId>
                        <artifactId>tomcat-embed-core</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.tomcat.embed</groupId>
                        <artifactId>tomcat-embed-logging-juli</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-rpc-default</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-rpc-injvm</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <!-- 
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-rpc-rmi</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-rpc-hessian</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.caucho</groupId>
                        <artifactId>hessian</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-rpc-http</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.caucho</groupId>
                        <artifactId>hessian</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-rpc-webservice</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-rt-frontend-simple</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-rt-transports-http</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-rpc-thrift</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.thrift</groupId>
                        <artifactId>libthrift</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-rpc-memcached</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.googlecode.xmemcached</groupId>
                        <artifactId>xmemcached</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-rpc-redis</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>redis.clients</groupId>
                        <artifactId>jedis</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-rpc-rest</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.jboss.resteasy</groupId>
                        <artifactId>resteasy-jaxrs</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jboss.resteasy</groupId>
                        <artifactId>resteasy-client</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jboss.resteasy</groupId>
                        <artifactId>resteasy-netty</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jboss.resteasy</groupId>
                        <artifactId>resteasy-jdk-http</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jboss.resteasy</groupId>
                        <artifactId>resteasy-undertow</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.undertow</groupId>
                        <artifactId>undertow-servlet</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>io.undertow</groupId>
                        <artifactId>undertow-core</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jboss.resteasy</groupId>
                        <artifactId>resteasy-jackson-provider</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jboss.resteasy</groupId>
                        <artifactId>resteasy-jaxb-provider</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>javax.validation</groupId>
                        <artifactId>validation-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-registry-default</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <!-- 
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-registry-multicast</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
             -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-registry-zookeeper</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.zookeeper</groupId>
                        <artifactId>zookeeper</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.github.sgroschupf</groupId>
                        <artifactId>zkclient</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.netflix.curator</groupId>
                        <artifactId>curator-framework</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <!-- 
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-registry-redis</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>redis.clients</groupId>
                        <artifactId>jedis</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
             -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-monitor-default</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-container-spring</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-container-javaconfig</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <!-- 
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-container-jetty</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.mortbay.jetty</groupId>
                        <artifactId>jetty</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
             -->
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-container-log4j</artifactId>
                <version>${project.parent.version}</version>
            </dependency>
            <dependency>
                <groupId>com.alibaba</groupId>
                <artifactId>dubbo-container-logback</artifactId>
                <version>${project.parent.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>ch.qos.logback</groupId>
                        <artifactId>logback-classic</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <artifactId>maven-source-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>attach-sources</id>
                            <phase>package</phase>
                            <goals>
                                <goal>jar-no-fork</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>attach-javadoc</id>
                            <phase>deploy</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <show>public</show>
                        <charset>UTF-8</charset>
                        <encoding>UTF-8</encoding>
                        <docencoding>UTF-8</docencoding>
                        <excludePackageNames>com.alibaba.com.*</excludePackageNames>
                        <links>
                            <link>http://docs.oracle.com/javase/6/docs/api</link>
                        </links>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>1.4</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                            <configuration>
                                <createSourcesJar>true</createSourcesJar>
                                <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
                                <artifactSet>
                                    <includes>
                                        <include>com.alibaba:hessian-lite</include>
                                        <include>com.alibaba:dubbo-common</include>
                                        <include>com.alibaba:dubbo-remoting-api</include>
                                        <include>com.alibaba:dubbo-remoting-netty</include>
                                        <!-- <include>com.alibaba:dubbo-remoting-mina</include>
                                        <include>com.alibaba:dubbo-remoting-grizzly</include>
                                        <include>com.alibaba:dubbo-remoting-p2p</include>
                                        <include>com.alibaba:dubbo-remoting-http</include> -->
                                        <include>com.alibaba:dubbo-remoting-zookeeper</include>
                                        <include>com.alibaba:dubbo-rpc-api</include>
                                        <include>com.alibaba:dubbo-rpc-default</include>
                                        <include>com.alibaba:dubbo-rpc-injvm</include>
                                        <!-- <include>com.alibaba:dubbo-rpc-rmi</include>
                                        <include>com.alibaba:dubbo-rpc-hessian</include>
                                        <include>com.alibaba:dubbo-rpc-http</include>
                                        <include>com.alibaba:dubbo-rpc-webservice</include>
                                        <include>com.alibaba:dubbo-rpc-thrift</include>
                                        <include>com.alibaba:dubbo-rpc-memcached</include>
                                        <include>com.alibaba:dubbo-rpc-redis</include> -->
                                        <include>com.alibaba:dubbo-rpc-rest</include>
                                        <include>com.alibaba:dubbo-filter-validation</include>
                                        <include>com.alibaba:dubbo-filter-cache</include>
                                        <include>com.alibaba:dubbo-cluster</include>
                                        <include>com.alibaba:dubbo-registry-api</include>
                                        <include>com.alibaba:dubbo-registry-default</include>
                                        <!-- <include>com.alibaba:dubbo-registry-multicast</include> -->
                                        <include>com.alibaba:dubbo-registry-zookeeper</include>
                                        <!-- <include>com.alibaba:dubbo-registry-redis</include> -->
                                        <include>com.alibaba:dubbo-monitor-api</include>
                                        <include>com.alibaba:dubbo-monitor-default</include>
                                        <include>com.alibaba:dubbo-config-api</include>
                                        <include>com.alibaba:dubbo-config-spring</include>
                                        <include>com.alibaba:dubbo-container-api</include>
                                        <include>com.alibaba:dubbo-container-spring</include>
                                        <include>com.alibaba:dubbo-container-javaconfig</include>
                                        <!-- <include>com.alibaba:dubbo-container-jetty</include> -->
                                        <include>com.alibaba:dubbo-container-log4j</include>
                                        <include>com.alibaba:dubbo-container-logback</include>
                                    </includes>
                                </artifactSet>
                                <transformers>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.common.compiler.Compiler</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.common.extension.ExtensionFactory</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.common.serialize.Serialization</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.common.status.StatusChecker</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.common.threadpool.ThreadPool</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.remoting.Dispatcher</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.remoting.Codec2</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.remoting.Transporter</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.remoting.exchange.Exchanger</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.remoting.http.HttpBinder</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.remoting.p2p.Networker</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.remoting.telnet.TelnetHandler</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.Protocol</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.Filter</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.InvokerListener</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.ExporterListener</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.ProxyFactory</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.cluster.Cluster</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.cluster.LoadBalance</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.cluster.Merger</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.cluster.RouterFactory</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.rpc.cluster.ConfiguratorFactory</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.container.Container</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.container.page.PageHandler</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.monitor.MonitorFactory</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.registry.RegistryFactory</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.validation.Validation</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.cache.CacheFactory</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.common.store.DataStore</resource>
                                    </transformer>
                                    <transformer
                                            implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                        <resource>META-INF/dubbo/internal/com.alibaba.dubbo.common.logger.LoggerAdapter</resource>
                                    </transformer>
                                </transformers>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </project>

     剔除dubbo-rpc-http后,唯一的一个额外调整是需要在业务应用工程中增加spring-web依赖,因为spring-web依赖不是配置在dubbo主工程中。

    常见问题:

    服务no provider

    Forbid consumer 10.30.50.239 access service com.htouhui.sms.service.MessageQueueService from registry 10.30.50.239:2181 use dubbo version 2.5.3, Please check registry access list (whitelist/blacklist).

     https://blog.csdn.net/ksdb0468473/article/details/72820268

    dubbo服务泛型的使用

    https://blog.csdn.net/xiaopihai86/article/details/67636021

    客户端只调用了一次,服务端执行了多次

    参考: 

    dubbox官网:https://github.com/dangdangdotcom/dubbox

    dubbo用户指南:http://dubbo.io/User+Guide-zh.htm

    dubbox rest开发:http://dangdangdotcom.github.io/dubbox/rest.html

    嵌入式tomcat 7.0,http://www.blogjava.net/wangxinsh55/archive/2016/07/18/431229.html

    dubbo annocation scan启动过程解析 http://blog.csdn.net/wangyunzhong/article/details/42029821

    基于Spring可扩展Schema提供自定义配置支持 http://blog.csdn.net/cutesource/article/details/5864562

  • 相关阅读:
    能否获取倒数第二个指定字符的位置? 截取
    css布局之头尾固定中间高度自适应
    C# Convert.ToInt32和int.Parse转换null和空字符串时的不同表现
    当前上下文中不存在viewbag
    IIS 7.5 上传文件大小限制
    git 学习笔记
    sql like 语句
    js文件,同样的路径,拷贝过来的为什么不能访问
    软件项目开发报价(一)
    asp.net core webapi 日期返回中出现字母T
  • 原文地址:https://www.cnblogs.com/zhjh256/p/6918359.html
Copyright © 2020-2023  润新知