我想构建一个包并将其安装到我的本地仓库.我的pom文件是:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.me</groupId>
<artifactId>MyApp</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
</properties>
<!-- This block declare a dependencies for this project -->
<dependencies>
<!-- Spring Boot -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<!-- This block declare a plugins -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
</plugin>
<!-- Installing to local repo -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<groupId>com.me</groupId>
<artifactId>MyApp</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<file>/Users/me/MyApp/target/MyApp-1.0.0.jar</file>
<generatePom>true</generatePom>
</configuration>
<executions>
<execution>
<id>install-jar-lib</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Run Code Online (Sandbox Code Playgroud)
但是当我运行"mvn package"命令时,我得到一个没有文件的错误:/Users/me/MyApp/target/MyApp-1.0.0.jar所以我评论安装插件,运行"mvn package",uncoment install plugin并运行"mvn包".我可以一步到位吗?没有这个评论 - 取消评论的事情?
目前尚不清楚为什么需要调用install-file目标,maven-install-plugin但问题在于阶段.你<phase>validate</phase>应该在什么时候配置它<phase>package</phase>.
看看构建生命周期简介:阶段validate是Maven执行的第一个阶段.这时,罐子没有建成,所以无法工作.
如果您确实希望在包阶段(运行时mvn package)安装工件,则应将阶段设置为package.
请注意mvn package,您应该mvn install在不需要配置的情况下调用而不是运行maven-install-plugin.使用此命令,工件将自动安装在本地仓库中.
| 归档时间: |
|
| 查看次数: |
2146 次 |
| 最近记录: |