【问题标题】:how to specify the full path along with the mvn executable in pom.xml如何在 pom.xml 中指定完整路径以及 mvn 可执行文件
【发布时间】:2015-12-02 19:54:51
【问题描述】:

在模块库的子 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%

【问题讨论】:

  • 你为什么要这个?将它放在您的环境中更为常见。但也许this 是您正在寻找的...
  • 是的,我正在寻找 pom.xml 以在构建时将 m2_home 放入路径中。
  • 为什么要通过 exec-maven-plugin 执行 maven?

标签: maven


【解决方案1】:

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

或者只是:

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

【讨论】:

    猜你喜欢
    • 2019-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 2012-10-20
    相关资源
    最近更新 更多