春季启动部署错误:java.lang.IllegalStateException:无法获取嵌套存档

时间:2018-10-19 00:28:40

标签: java spring spring-boot gradle intellij-idea

我正在尝试在Ubuntu 16计算机上部署spring-boot应用程序。

该应用程序可以从Intellij正常运行。构建工具是gradle。

标题错误是:

java - jar assessment-0.0.1-SNAPSHOT.jar nz.org.assessment.Application
Exception in thread "main" java.lang.IllegalStateException Failed to get nested archive for entry BOOT-INF/lib/root-7.1.3.pom

build.gradle是:

buildscript {
ext {
    springBootVersion = '2.0.3.RELEASE'
}
repositories {
    maven {
        url("https://plugins.gradle.org/m2/")
    }
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'application'

mainClassName = "nz.org.assessment.Application"

group = 'nz.org.assessment'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    maven {
        url("https://plugins.gradle.org/m2/")
    }
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-mail')

    compile('org.springframework.boot:spring-boot-starter-thymeleaf')
    compile('org.springframework.boot:spring-boot-starter-validation')
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.session:spring-session-core')
    runtime('org.springframework.boot:spring-boot-devtools')
    testCompile('org.springframework.boot:spring-boot-starter-test')
    testCompile('org.springframework.security:spring-security-test')
    compile group: 'org.thymeleaf', name: 'thymeleaf', version: '3.0.9.RELEASE'

    compile group: 'org.jsoup', name: 'jsoup', version: '1.11.2'

    compile group: 'commons-io', name: 'commons-io', version: '2.6'

    compile 'org.springframework.boot:spring-boot-starter-data-jpa'
    compile 'mysql:mysql-connector-java'
    }

该代码可在IDE中正常运行。

部署的代码位于具有单独jar的lib文件夹中。我已经从Intellij的gradle菜单中运行了“ distZip”任务。

1 个答案:

答案 0 :(得分:1)

解决方案是从春季启动2开始使用不同的gradle插件。要构建可执行的jar,我需要使用 bootJar

https://guides.gradle.org/building-spring-boot-2-projects-with-gradle/