gradle构建springboot多模块项目配置

父模块配置 > build.gradle

buildscript {
//统一版本管理
ext {
springBootVersion = '2.3.12.RELEASE'
springCloudVersion = 'Hoxton.SR12'
springCloudAlibabaVersion = '2.2.9.RELEASE'
}
//仓库
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
//全局配置
allprojects {
group 'com.dq.ggac'
version '1.0'
apply plugin: 'idea'
apply plugin: "java"
apply plugin: "org.springframework.boot"
apply plugin: "io.spring.dependency-management"
//java版本
sourceCompatibility = 11
targetCompatibility = 11
//编码
tasks.withType(JavaCompile){
options.encoding ="UTF-8"
}
//仓库
repositories {
maven{ url 'http://maven.aliyun.com/nexus/content/groups/public/'}
mavenCentral()
}
}
//配置子项目
subprojects {
dependencyManagement{
imports{
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
mavenBom "com.alibaba.cloud:spring-cloud-alibaba-dependencies:${springCloudAlibabaVersion}"
}
}
dependencies {
//lombok
compileOnly group: 'org.projectlombok', name: 'lombok', version: '1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.2'
//swagger+knife4j
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
compile group: 'io.swagger', name: 'swagger-annotations', version: '1.5.22'
compile group: 'io.swagger', name: 'swagger-models', version: '1.5.22'
compile group: 'com.github.xiaoymin', name: 'knife4j-spring-boot-starter', version: '2.0.4'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-validation'
}
}

子模块配置 client-service > build.gradle

bootJar {
enabled = true
}
dependencies {
compile project(':core')
compile('org.springframework.boot:spring-boot-starter-test')
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
implementation('org.springframework.boot:spring-boot-starter-jdbc')
runtimeOnly('mysql:mysql-connector-java')
compile group: 'com.alibaba', name: 'fastjson', version: '1.2.58'
compile('org.springframework.boot:spring-boot-starter-data-redis')
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
compile 'org.apache.httpcomponents:httpclient:4.5.6'
}

核心依赖模块配置 core > build.gradle

jar {
enabled = true
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-test')
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
implementation('org.springframework.boot:spring-boot-starter-jdbc')
runtimeOnly('mysql:mysql-connector-java')
compile group: 'com.alibaba', name: 'fastjson', version: '1.2.58'
compile('org.springframework.boot:spring-boot-starter-data-redis')
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
compile 'org.apache.httpcomponents:httpclient:4.5.6'
compile('com.vladmihalcea:hibernate-types-52:2.4.1')
}
posted @   码农记事本  阅读(410)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示