我使用 install:install-file 将 jar 安装到我的本地存储库。我的 pom.xml 编写如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>install-paho</id>
<phase>generate-resources</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${basedir}/lib/paho.jar</file>
<groupId>org.eclipse</groupId>
<artifactId>paho</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>
您可以发现我将其绑定到“生成资源”阶段。然后,我使用顺序mvn eclipse:eclipse
.它工作得很好,jar 被复制到我的本地存储库。但是当我使用 order 时mvn install:install-file
我收到错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file (default-cli) on project xxx:
The parameters 'file' for goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file are missing or invalid -> [Help 1]
使用时的错误提示mvn compile
[ERROR] Failed to execute goal on project android-engine: Could not resolve dependencies for project com.youku.wireless:android-engine:jar:1.0-SNAPSHOT: Could not find artifact org.eclipse:paho:jar:1.0.0 in spring-milestone (http://maven.springframework.org/milestone) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
既然你已经绑定了install:install-file
目标为generate-sources
阶段,你应该运行mvn compile
or mvn install
或类似的使用定义的配置。
mvn eclipse:eclipse
有效,因为 Maven 运行generate-sources
调用之前的阶段eclipse:eclipse
.
Edit:从评论看来你想使用本地可用的paho.jar
在您的项目中,首先将其安装到本地存储库中generate-sources
阶段,然后将其用作dependency
在你的项目中。
这是行不通的,因为 Maven 检查可用性dependencies
在开始执行其生命周期目标之前。
您可以使用一次性手动安装它mvn install:install-file
在 pom 的上下文之外。更好的是,您可以将其部署到repository manager
然后像任何其他依赖项一样访问它。
但是,如果您仍然想走这条路,另一种方法是使用system
范围提供 jar 的路径。参考this http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies.
<project>
...
<dependencies>
<dependency>
<groupId>org.eclipse</groupId>
<artifactId>paho</artifactId>
<version>1.0.0/version>
<scope>system</scope>
<systemPath>${basedir}/lib/paho.jar</systemPath>
</dependency>
</dependencies>
...
</project>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)