java - 目标 org.springframework.boot :spring-boot-maven-plugin:1. 的执行默认值 2.3.RELEASE:repackage failed: Source must reference an existing file

标签 java maven spring-boot

我想使用 maven-jar-plugin 来构建差异分类器 jar,例如:

mvn deploy:deploy -P debug ,已部署classifier-demo-0.0.1-debug.jar

mvn deploy:deploy -P test ,已部署classifier-demo-0.0.1-test.jar。

但失败:

Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.2.3.RELEASE:repackage failed: Source must refer to an existing file

pom.xml :
<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>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.2.3.RELEASE</version>
</parent>
<groupId>org.lenic</groupId>
<artifactId>classifier-demo</artifactId>
<version>0.0.1</version>
<properties>
    <java.version>1.7</java.version>
</properties>

<distributionManagement>
    <repository>
        <id>local-repo</id>
        <url>file://D:\repo</url>
    </repository>
</distributionManagement>

<profiles>
    <profile>
        <id>test</id>
        <properties>
            <classifier>test</classifier>
        </properties>
    </profile>
    <profile>
        <id>debug</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <properties>
            <classifier>debug</classifier>
        </properties>
    </profile>
</profiles>
<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <classifier>${classifier}</classifier>
            </configuration>
        </plugin>
    </plugins>
</build>

最佳答案

目标:重新包装
Repackage 尝试重新打包原始 Artifact ,即 projectName.jar。这是 maven 默认包阶段的结果,即 mvn 包 命令输出。

当 Repackage 目标执行时,它会尝试查找 projectName.jar。

当您运行 mvn spring-boot:package 时,projectName.jar 不存在。
这就是为什么它会给出错误 源必须引用现有文件

解决方案:
运行命令
mvn clean package spring-boot:repackage

关于java - 目标 org.springframework.boot :spring-boot-maven-plugin:1. 的执行默认值 2.3.RELEASE:repackage failed: Source must reference an existing file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29406448/

相关文章:

java - 获取maven插件在自己的Mojo中的目录路径

java - 如何创建多模块 spring mvc 应用程序

java - 带有 Logback 的 Spring Boot 应用程序不会作为 Systemd 服务登录到指定位置

java - jsf动态变化managedbean

java - 使用 Java 创建 'HTTP Redirect Binding' SAML 请求

java - JDBC 连接到 MYSQL 不使用代号一

java - Spring Boot TCP 客户端

java - ActionListener 和 event.getSource()

android - 在应用程序中导入我的 android 库不被识别为库

java - ProGuard:警告:org.apache.commons.beanutils.BeanMap$2:找不到父类(super class)或接口(interface) org.apache.commons.collections.Transformer