java --jars 多个_java – Spring Boot多模块Gradle构建 – 多个“Fat Jars”

我们的spring-boot项目如下所示

project

|__ build.gradle

|__ settings.gradle

|__ module_a

|__ module_b

|__ ...

|__ module_a

|__ module_b

module_a仅包含SpringApplication类和文件application.properties

运行./gradlew build工作正常,但问题是,对于每个模块(大约10)gradle生成一个包含所有依赖项的胖jar.

我们想只有一个远罐(在模块a中)

buildscript {

ext {

springBootVersion = '1.2.0.RELEASE'

springLoadedVersion = '1.2.0.RELEASE'

}

repositories {

// NOTE: You should declare only repositories that you need here

mavenCentral()

maven { url "http://repo.spring.io/release" }

maven { url "http://repo.spring.io/milestone" }

maven { url "http://repo.spring.io/snapshot" }

}

dependencies {

classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")

classpath("org.springframework:springloaded:${springLoadedVersion}")

}

}

allprojects {

group = "example.group"

version = "0.0.1"

repositories() {

mavenCentral()

}

}

subprojects {

apply plugin: "groovy"

apply plugin: "eclipse"

eclipse {

classpath {

containers.remove("org.eclipse.jdt.launching.JRE_CONTAINER")

containers "org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"

}

}

apply plugin: "idea"

apply plugin: "java"

apply plugin: "spring-boot"

mainClassName = "MainClassName"

sourceCompatibility = 1.8

targetCompatibility = 1.8

dependencies {

}

}

task wrapper(type: Wrapper) { gradleVersion = '2.2' }

我们尝试添加选项

jar.enabled = false

bootRepackage.enabled = false

在子项目部分,但在那之后,该项目不再漫画.

解决方法:

您可以将它仅应用于module_a,而不是将Spring Boot插件应用于每个子项目:

project(':module_a') {

apply plugin: 'org.springframework.boot'

}

标签:java,spring,gradle,spring-boot-2

来源: https://codeday.me/bug/20190609/1206512.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值