首页 > 其他分享 >gradle构建springboot多模块项目配置

gradle构建springboot多模块项目配置

时间:2023-02-06 17:14:32浏览次数:34  
标签:springboot spring boot springframework gradle compile 模块 org starter

父模块配置 > 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')
}

标签:springboot,spring,boot,springframework,gradle,compile,模块,org,starter
From: https://www.cnblogs.com/z8080/p/17095925.html

相关文章