Dubbo学习笔记--- 抽取重复接口以及统一依赖版本
Posted java小白逆袭之路
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Dubbo学习笔记--- 抽取重复接口以及统一依赖版本相关的知识,希望对你有一定的参考价值。
你真的很特别
本节源码下载:
https://github.com/icat-xb/dubbo-parent/tree/dubbo-parent-ver1.0
工具包下载:
链接:https://pan.baidu.com/s/11B-Kn8LJEtPBtfdx3jhDzw
提取码:8sca
创建maven项目
创建三个maven子项目
dubbo-demo-consumer,
dubbo-demo-provider,
dubbo-demo-api
抽取重复接口
抽取重复接口DemoProviderService
package com.icat.service;
/**
* 服务提供者/消费者接口
* @author icat
*
*/
public interface DemoProviderService {
public String sayHello(String name);
}
pom.xml分别添加依赖
<dependency>
<groupId>com.icat</groupId>
<artifactId>dubbo-demo-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
统一依赖包版本
添加依赖
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.icat</groupId>
<artifactId>dubbo-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>dubbo-demo-consumer</module>
<module>dubbo-demo-provider</module>
<module>dubbo-demo-api</module>
</modules>
<!-- 依赖版本管理 -->
<properties>
<dubbo-demo-api.version>0.0.1-SNAPSHOT</dubbo-demo-api.version>
<dubbo.version>2.6.0</dubbo.version>
<zkclient.version>0.10</zkclient.version>
<curator-framework.version>4.0.1</curator-framework.version>
<fastjson.version>1.2.46</fastjson.version>
<log4j.version>1.2.17</log4j.version>
<slf4j-api.version>1.7.25</slf4j-api.version>
<commons-lang3.version>3.4</commons-lang3.version>
<netty-all.version>4.0.35.Final</netty-all.version>
</properties>
<!-- 依赖管理 -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.icat</groupId>
<artifactId>dubbo-demo-api</artifactId>
<version>${dubbo-demo-api.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>${zkclient.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>${curator-framework.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j-api.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>${netty-all.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
修改依赖
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.icat</groupId>
<artifactId>dubbo-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>dubbo-demo-provider</artifactId>
<dependencies>
<dependency>
<groupId>com.icat</groupId>
<artifactId>dubbo-demo-api</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
</dependencies>
</project>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.icat</groupId>
<artifactId>dubbo-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>dubbo-demo-consumer</artifactId>
<dependencies>
<dependency>
<groupId>com.icat</groupId>
<artifactId>dubbo-demo-api</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
</dependencies>
</project>
测试
粉丝特别福利
最新整理了2000G的java从入门到大神所需干货;
涵盖java初级,中级,高级,架构课程;
涵盖j2ee项目20个++;
涵盖springcloud项目课程6个++
涵盖初级到BAT笔试面试题;
涵盖简历模版,项目素材;
获取方式:扫描下方二维码,在台打开回复 【福利】即可领取,资料持续更新!
获取2000Gjava从菜鸡到大神资料
(回复 福利 获取)
以上是关于Dubbo学习笔记--- 抽取重复接口以及统一依赖版本的主要内容,如果未能解决你的问题,请参考以下文章