在以前的帖子中寻找答案没有成功。 问题是:gradle任务fatJar并未将所有依赖项包含在内。
解压缩jar时得到的是我的src / main / java类,在我自己的情况下,其余的依赖项(独立于Spring Boot依赖项)在一个单独的jar中。
重要的是,我的gradle是一个多模块项目
以下片段是我的基本gradle.build和子项目gradle.build
基本gradle.build:
buildscript {
ext {
springCloudVersion = 'Finchley.RELEASE'
springCloudStreamVersion = 'Elmhurst.RELEASE'
springBootVersion = '2.0.5.RELEASE'
}
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
repositories {
mavenCentral()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url 'https://oss.jfrog.org/libs-release' }
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-webflux')
compile('org.springframework.boot:spring-boot-starter-actuator')
compile("org.springframework.boot:spring-boot-starter-thymeleaf")
compile('org.springframework.boot:spring-boot-starter-data-redis-reactive')
compile('org.springframework.boot:spring-boot-configuration-processor')
compile('org.springframework.boot:spring-boot-devtools')
compile('org.projectlombok:lombok')
// compile('org.apache.logging.log4j:log4j-core:2.11.1')
// compile('org.apache.logging.log4j:log4j-api:2.11.1')
compile('org.springframework.cloud:spring-cloud-stream-reactive')
compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-client')
// compile('org.springframework.cloud:spring-cloud-starter-netflix-hystrix')
// compile('org.springframework.cloud:spring-cloud-starter-config')
// compile('org.apache.logging.log4j:log4j-core:2.11.1')
// compile('org.apache.logging.log4j:log4j-api:2.11.1')
compile('io.projectreactor.addons:reactor-test:3.0.7.RELEASE')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
test {
exclude '**/*'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
mavenBom "org.springframework.cloud:spring-cloud-stream-dependencies:${springCloudStreamVersion}"
}
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
子项目graddle.build
plugins {
id "com.gorylenko.gradle-git-properties" version "1.4.17"
}
configurations {
all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
all*.exclude group: 'org.springframework', module: 'spring-webmvc'
}
dependencies {
compile('net.sourceforge.stripes:stripes:1.7.0-async-beta')
}
task fatJar(type: Jar) {
manifest.from jar.manifest
baseName = project.name + '-all'
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
artifacts {
archives fatJar
}