我想使用 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/