繁体   English   中英

目标org.springframework.boot的执行默认值:spring-boot-maven-plugin:1.4.0.RELEASE:repackage failed: Unable to rename

[英]Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage failed: Unable to rename

我正在尝试从 spring 项目中构建 JAR 文件。 当我尝试进行 maven 安装时,它会抛出以下错误

Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage (default) on project ABC: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage failed: Unable to rename 'ABC-0.0.1-SNAPSHOT.jar' to 'ABC-0.0.1-SNAPSHOT.jar.original' ->

'pom' 文件如下所示

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>ABC</groupId> <artifactId>ABC</artifactId> <version>0.0.1-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.4.0.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-configuration2</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>com.googlecode.json-simple</groupId> <artifactId>json-simple</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>5.0.0.RELEASE</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>5.0.2.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> <version>1.5.9.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>1.5.9.RELEASE</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.7.0</version> </dependency> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> < --$NO-MVN-MAN-VER$--> <scope>provided</scope> </dependency> </dependencies>

pom文件的build部分如下图

 <build> <sourceDirectory>src</sourceDirectory> <plugins> <.-- Set a compiler level --> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.3</version> <.--$NO-MVN-MAN-VER$--> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> < -- For Generating the Jar File --> <plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>ABCapp</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin> < -- Generating jar file which has Spring boot application --> <plugin> <groupId>org springframework boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <mainClass>${start-class}</mainClass> <layout>JAR</layout> <includeSystemScope>true</includeSystemScope> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project>

我试图在 SO 和其他论坛中寻找可能的解决方案。 但他们都没有工作。 关于问题可能出在哪里的任何指示?

虽然问题并没有完全消失,但现在解决问题的是使用SO的答案

<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <classifier>boot</classifier> </configuration> </plugin>

它现在创建一个额外的 *.jar 文件 (ABC-boot.jar)。

TL;DR:检查 Jar 名称中的特殊字符

就我而言,问题与 pom.xml 中的这些行有关:

 <version>1.0.0-${maven.build.timestamp}</version> <maven.build.timestamp.format>yyyy-MM-dd-HH:mm</maven.build.timestamp.format>

有趣的是,这是特定于操作系统的 - 我在执行mvn clean install时遇到了与提问者相同的错误。 它适用于 Linux。

暂无
暂无

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

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