二、idea+gradle配置给springcloud每个子模块打jar包 及 打docker镜像

一、子模块打jar包

1、根项目build.gradle配置

buildscript {
    ext {
        springBootVersion = '2.2.5.RELEASE'
        springCloudVersion = 'Hoxton.SR1'
    }
    repositories {
        mavenLocal()
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}
allprojects {
    group 'com.trgis'
    version '1.0.0.0'
    apply plugin: 'java'
    // 指定JDK版本
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    //指定编码格式
    tasks.withType(JavaCompile) {
        options.encoding = "UTF-8"
    }

    repositories {
        mavenLocal()
        maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
        mavenCentral()
    }
}

subprojects {
    //dependency-management 插件
    apply plugin: 'io.spring.dependency-management'
    dependencyManagement {
        imports {
            //spring bom helps us to declare dependencies without specifying version numbers.
            mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
            mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
        }
    }
    jar {
        manifest.attributes provider: 'gradle'
    }
}

2、子模块build.gradle配置:dependencies 中的内容根据模块实际需要配置

apply plugin: 'org.springframework.boot'
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.cloud:spring-cloud-starter-consul-discovery'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

3、还有根项目settings.gradle中引入所有子模块

rootProject.name = 'demo'
include 'demo-server'

4、双击运行gradle->跟项目中->Tasks->build->build

结果如下:会在每个子模块下创建build文件夹,打包的jar文件在build->libs文件夹中

二、子模块打docker镜像

参照https://blog.csdn.net/weixin_41996632/article/details/100705901

给每个子模块中添加自动打包依赖,执行即可

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值