代码之家  ›  专栏  ›  技术社区  ›  Al Grant

Spring引导部署错误:java.lang.IllegalStateException:未能获取嵌套存档

  •  1
  • Al Grant  · 技术社区  · 7 年前

    我正试图在Ubuntu16计算机上部署一个SpringBoot应用程序。

    应用程序从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 回复  |  直到 7 年前
        1
  •  1
  •   Al Grant    7 年前

    解决方案是springboot2forwards使用不同的gradle插件。要构建一个我需要使用的可执行jar 引导器

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