【问题标题】:Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (default) on project ors: The parameter 'executable' is missing or invalid无法在项目 ors 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.6.0:exec (默认):参数“executable”丢失或无效
【发布时间】:2017-09-19 11:22:28
【问题描述】:

当我尝试执行 mvn -DskipTests=true -Passembly assembly:directory exec:exec 命令来制作二进制文件时,我得到了 无法在项目 ors 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.6.0:exec(默认):参数“executable”丢失或无效错误。我还在配置中应用了 Source Target 1.8,但仍然遇到同样的错误。

<profile>
      <id>execute</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
              <executions>
                  <execution>
                      <goals><goal>java</goal></goals>
                  </execution>
              </executions>
          <configuration>
          <mainClass>org.marketcetera.ors.OrderRoutingSystem</mainClass>
          <systemProperties>
              <systemProperty>
                  <key>org.marketcetera.appDir</key>
                  <value>src/test/cmd_exec</value>
              </systemProperty>
          </systemProperties>
          <classpathScope>test</classpathScope>
          </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Command-line execution of the ORS (with DB initialization). -->
    <profile>
      <id>executeDBInit</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
              <executions>
                  <execution>
                      <goals><goal>java</goal></goals>
                  </execution>
              </executions>
          <configuration>
        <mainClass>org.marketcetera.ors.DBInit</mainClass>
        <arguments>
          <argument>org.marketcetera.ors.OrderRoutingSystem</argument>
        </arguments>
        <systemProperties>
          <systemProperty>
            <key>org.marketcetera.appDir</key>
            <value>src/test/cmd_exec</value>
          </systemProperty>
        </systemProperties>
        <classpathScope>test</classpathScope>
          </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Command-line execution of the miniscule exchange. -->
    <profile>
      <id>exchange</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
              <executions>
                  <execution>
                      <goals><goal>java</goal></goals>
                  </execution>
              </executions>
          <configuration>
        <mainClass>org.marketcetera.ors.exchange.Main</mainClass>
        <arguments>
          <argument>exchange.xml</argument>
        </arguments>
        <systemProperties>
          <systemProperty>
            <key>org.marketcetera.appDir</key>
            <value>src/test/cmd_exec</value>
          </systemProperty>
        </systemProperties>
        <classpathScope>test</classpathScope>
          </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Security administration utility. -->
    <profile>
      <id>cli</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
              <executions>
                  <execution>
                      <goals><goal>java</goal></goals>
                  </execution>
              </executions>
          <configuration>
        <mainClass>org.marketcetera.ors.security.ORSAdminCLI</mainClass>
        <!-- -Dexec.args="-u admin ..." -->
        <systemProperties>
          <systemProperty>
            <key>org.marketcetera.appDir</key>
            <value>src/test/cmd_exec</value>
          </systemProperty>
        </systemProperties>
        <classpathScope>test</classpathScope>
          </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Assembly. -->
    <profile>
      <id>assembly</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
              <executions>
                  <execution>
                      <phase>package</phase>
                      <goals><goal>single</goal></goals>
                      <configuration>
                          <formats><format>dir</format></formats>
                          <descriptors>
                              <descriptor>src/main/assembly/assembly.xml</descriptor>
                          </descriptors>
                      </configuration>
                  </execution>
              </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
              <executions>
                  <execution>
                      <phase>package</phase>
                      <goals><goal>exec</goal></goals>
                      <configuration>
              <executable>${perl.path}</executable>
                          <arguments>
                              <argument>../tools/scripts/createScript.pl</argument>
                              <argument>${project.build.directory}/${project.artifactId}</argument>
                              <argument>ors</argument>
                              <argument>org.marketcetera.ors.OrderRoutingSystem</argument>
                              <argument>${project.build.directory}/${project.artifactId}</argument>
                              <argument>orsadmin</argument>
                              <argument>org.marketcetera.ors.security.ORSAdminCLI</argument>
                          </arguments>
                      </configuration>
                  </execution>
              </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

【问题讨论】:

    标签: java maven


    【解决方案1】:

    我通过在 pom.xml 中指定所需的插件解决了这个错误,如下所示

                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>3.0.0</version>
                    <configuration>
                        <executable>java</executable>
                        <arguments>
                            <argument>-classpath</argument>
                            <classpath />
                            <argument>com.ocloud.Alarm.App</argument>
                        </arguments>
                    </configuration>
                </plugin>
    

    【讨论】:

      【解决方案2】:

      从 exec-maven-plugin 版本 1.6.0 开始,除非您指定 id,否则 &lt;execution&gt; 块中的 &lt;configuration&gt; 部分将被忽略。

      尝试更改您的命令行,将 exec:exec@foo 替换为 exec:exec,并将插件块更改为包含 id foo如下:

            <plugin>
              <groupId>org.codehaus.mojo</groupId>
              <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>foo</id>
                        <phase>package</phase>
                        <goals><goal>exec</goal></goals>
                        <configuration>
                <executable>${perl.path}</executable>
                            <arguments>
                                <argument>../tools/scripts/createScript.pl</argument>
                                <argument>${project.build.directory}/${project.artifactId}</argument>
                                <argument>ors</argument>
                                <argument>org.marketcetera.ors.OrderRoutingSystem</argument>
                                <argument>${project.build.directory}/${project.artifactId}</argument>
                                <argument>orsadmin</argument>
                                <argument>org.marketcetera.ors.security.ORSAdminCLI</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
      

      【讨论】:

        【解决方案3】:

        您忘记在&lt;executable&gt; 标记中指定perl.path 变量。

        <executable>${perl.path}</executable>
        

        将此添加到您的 pom 父级:

        <properties>
            <perl.path>path/to/perl</perl.path>       
        </properties>
        

        【讨论】:

        • 非常感谢你的建议,但我已经在最后一个 标签的 标签中维护了 ${perl.path}
        • 我明白了。但是你指定 perl.path 变量的值了吗?
        • 我已经在系统变量“C:\Program Files\strawberry\perl\bin”中指定了 perl.path 变量的值。
        猜你喜欢
        • 2019-08-16
        • 2016-10-05
        • 1970-01-01
        • 2014-03-10
        • 1970-01-01
        • 1970-01-01
        • 2019-05-01
        • 2022-12-11
        • 2016-11-24
        相关资源
        最近更新 更多