如何在pom.xml中指定完整路径以及mvn可执行文件

时间:2014-03-11 14:13:28

标签: maven

在模块库的子pom.xml中获取此错误

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (install-uum) on project libs: Command execution failed. Cannot run program "mvn" (in directory "D:\xyz\build\project_name\Build\app_name\libs"): CreateProcess error=2, The system cannot find the file specified

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>install-uum</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>mvn</executable>
<arguments>
<argument>install:install-file</argument>
<argument>-Dfile=${basedir}/entity-service-1.0.0.jar</argument>
<argument>-DgroupId=com.xyz.app</argument>
<argument>-DartifactId=entity-service</argument>
<argument>-Dversion=1.0.0</argument>
<argument>-Dpackaging=jar</argument>
</arguments>
</execution>

看起来maven未在路径中设置。有没有什么办法可以从pom.xml在PATH中设置maven可执行文件,而不是从命令行执行set PATH=%M2_HOME%\bin;%PATH%

1 个答案:

答案 0 :(得分:0)

在您的环境中设置M2_HOME变量以匹配Maven安装的位置应该足够

或者只是:

  • 包含maven安装bin目录的绝对路径
  • 添加“.bat”扩展程序
<executable>"path to your maven installation"\bin\mvn.bat</executable>