Dubbo-002

Posted yikuandyk

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dubbo-002相关的知识,希望对你有一定的参考价值。

1.引入Dubbo相关依赖:

        <dubbo.version>2.5.3</dubbo.version>
        <zookeeper.version>3.4.7</zookeeper.version>
        <zkclient.version>0.1</zkclient.version>
        
        <!-- dubbo相关 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <version>${dubbo.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <version>${zookeeper.version}</version>
        </dependency>
        <dependency>
            <groupId>com.github.sgroschupf</groupId>
            <artifactId>zkclient</artifactId>
            <version>${zkclient.version}</version>
        </dependency>

 

2.在service服务层发布Dubbo服务:(记得去掉与spring冲突的jar包)

        applicationContext-service.xml:
        
            <!-- 发布dubbo服务 -->
            <!-- 提供方应用信息,用于计算依赖关系 -->
            <dubbo:application name="taotao-manager" />
            <!-- 注册中心的地址 -->
            <dubbo:registry protocol="zookeeper" address="192.168.132.128:2181" />
            <!-- 用dubbo协议在20880端口暴露服务 -->
            <dubbo:protocol name="dubbo" port="20880" />
            <!-- 声明需要暴露的服务接口 -->
            <dubbo:service interface="com.taotao.service.ItemService"
                ref="itemServiceImpl" />
        pom.xml:

            <!-- dubbo相关 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>spring</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>netty</artifactId>
                    <groupId>org.jboss.netty</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.sgroschupf</groupId>
            <artifactId>zkclient</artifactId>
        </dependency>

 

3.在web视图层引用Dubbo服务:

springmvc.xml:


    <!-- 引用dubbo服务 -->
    <dubbo:application name="taotao-manager-web" />
    <dubbo:registry protocol="zookeeper" address="192.168.132.128:2181" />
    <dubbo:reference interface="com.taotao.service.ItemService"
        id="itemService" />


pom.xml:

<!-- dubbo相关 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>spring</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>netty</artifactId>
                    <groupId>org.jboss.netty</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.sgroschupf</groupId>
            <artifactId>zkclient</artifactId>
        </dependency>

 

以上是关于Dubbo-002的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数