首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >目标org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage的默认执行失败:无法重命名

目标org.springframework.boot:spring-boot-maven-plugin:1.4.0.RELEASE:repackage的默认执行失败:无法重命名
EN

Stack Overflow用户
提问于 2018-02-21 07:55:39
回答 2查看 8.1K关注 0票数 6

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

代码语言:javascript
运行
复制
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‘文件如下所示

代码语言:javascript
运行
复制
<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文件的构建部分如下所示

代码语言:javascript
运行
复制
    <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>   

我试图在这样和其他论坛寻找一个可能的解决方案。但他们都没用。有任何关于问题可能在哪里的提示吗?

EN

回答 2

Stack Overflow用户

发布于 2018-02-22 05:51:54

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

代码语言:javascript
运行
复制
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
        <classifier>boot</classifier>
    </configuration>
</plugin>

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

票数 0
EN

Stack Overflow用户

发布于 2020-05-26 13:59:24

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

在我的例子中,问题与pom.xml中的这些行有关:

代码语言:javascript
运行
复制
<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上工作。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48900700

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档