Dubbo-Gradle-Build
源码:https://github.com/xuanfong1/DubboLearning
新建目录
mkdir DubboLearning
,然后cd Dubbolearning
进去之后执行gradle init
初始化gradle项目新建三个子项目目录
mkdir library,provider,consumer
分别为公共依赖项目、提供者、消费者复制build.gradle到三个子项目目录
分别为三个子项目创建目录
mkdir -p src/main/java,src/test/java,src/main/resources
修改顶级项目目录的setting.gradle添加三个子项目
1
2
3include 'library'
inclede 'provider'
inclede 'consumer'复制项目helloworld的源码到项目目录
然后修改顶级项目目录build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29plugins {
id "org.springframework.boot" version "2.0.1.RELEASE"
}
allprojects {
repositories {
jcenter() //将jcenter仓库配置到所有项目
}
}
subprojects {
version = '1.0' //设置版本号
}
configure(subprojects.findAll {it.name == 'provider' || it.name == 'consumer'} ) {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: "org.springframework.boot"
apply plugin: 'io.spring.dependency-management'
group = 'exxk.dubbo'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile group: 'com.alibaba', name: 'dubbo', version: '2.6.1'
testCompile('org.springframework.boot:spring-boot-starter-test')
compile project(':library')
}
}
额外
https://plugins.gradle.org/plugin/org.springframework.boot
1 | //低版本,动态 |
报错:
1 | Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/curator/RetryPolicy |
解决:添加依赖compile group: 'org.apache.curator', name: 'curator-framework', version: '4.0.1'