简体   繁体   English

从 SpringBoot 在 JarWriter 上构建 Gradle CLI 失败

[英]Gradle CLI build fails on JarWriter from SpringBoot

Error message:错误信息:

 FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':bootRepackage'. > MALFORMED * Try: Run with --debug option to get more log output. * Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':bootRepackage'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)

.... ....

 Caused by: java.lang.IllegalArgumentException: MALFORMED at org.springframework.boot.loader.tools.JarWriter.writeEntries(JarWriter.java:92) at org.springframework.boot.loader.tools.Repackager.repackage(Repackager.java:144)

Settings:设置:
Java version:爪哇版:
java version "1.8.0_31" java版本“1.8.0_31”
Java(TM) SE Runtime Environment (build 1.8.0_31-b13) Java(TM) SE 运行时环境(构建 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode) Java HotSpot(TM) 64 位服务器 VM(构建 25.31-b07,混合模式)

build.gradle构建.gradle

 import org.apache.tools.ant.filters.ReplaceTokens import java.util.Date def profile = "PROD"; buildscript { ext { springBootVersion = '1.0.2.RELEASE' //**have tried with 1.2.4 as well** } repositories { mavenLocal() 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}") } } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea' apply plugin: 'spring-boot' mainClassName = "dk.api.gas.Gas" compileJava.options.encoding = 'UTF-8' sourceCompatibility = 1.7 targetCompatibility = 1.7 compileJava.options.encoding = "UTF-8" jar { baseName = 'quotes' version = '1.0.0' } repositories { mavenCentral() maven { url "http://repo.springsource.org/libs-snapshot" } maven {url "http://xxxxx.compute.amazonaws.com/artifactory/gradle/" credentials { username 'xx' password 'xxxx' } } } dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile("org.springframework.boot:spring-boot-starter-aop:${springBootVersion}") compile("com.fasterxml.jackson.core:jackson-databind") compile('dk.mobile:fileStorageLib:1.4.0') { exclude module: 'dk.mobile:common' } compile('dk.mobile:common:2.0.0') compile('dk.mobile:mail:1.0.5') compile('dk.mobile:update:1.1.0') { exclude module: 'dk.mobile:common' } compile('org.apache.solr:solr-solrj:3.1.0') compile('dk.mobile:authentication:1.3.0') { exclude module: 'dk.mobile:common' } compile('com.googlecode.charts4j:charts4j:1.3') compile('org.apache.poi:poi-ooxml:3.12') } def getDate() { def date = new Date() def formattedDate = date.format('dd.MM.yyy - HH:mm:ss') return formattedDate } processResources { filter ReplaceTokens, tokens: ["AppProfile": profile ] } task wrapper(type: Wrapper) { gradleVersion = '1.11' }

I had the same problem when building on Windows.我在 Windows 上构建时遇到了同样的问题。 The issue was that I had files with long names so their path went over 256 chars and made the zipping crash and the bootRepackage fail.问题是我有长名称的文件,所以它们的路径超过 256 个字符,导致压缩崩溃和 bootRepackage 失败。

On Linux on the other hand I didn't have any problem building the same application.另一方面,在 Linux 上,我在构建相同的应用程序时没有任何问题。

Hope this helped.希望这有帮助。

Another problem might be that you have files with non ascii characters.另一个问题可能是您的文件包含非 ascii 字符。

We hit the same error because of a few class names that used german umlauts ( ä , ö , ü ).我们遇到了同样的错误,因为一些类名使用了德语变音符号( äöü )。 After renaming the classes the problem went away (on Windows).重命名类后,问题就消失了(在 Windows 上)。

我在windows下建的时候也遇到了同样的问题,问题是reources/statics/images/未命名.png文件,不能使用汉字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM