无法执行目标org.codehaus.mojo:exec-maven-plugin:1.4.0:exec

时间:2016-07-18 14:20:50

标签: java spring maven

我一直在尝试在maven上运行程序。它应该连接到码头服务器。但是我一直收到以下错误:

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec (default-cli) on project broker-core: The parameters 'executable' for goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec are missing or invalid -> [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/PluginParameterException

我之前看到过人们遇到过同样的问题,不过我不明白如何解决这个问题。 我试过跑:

mvn exec:java -Dexec.mainClass=org.powertac.samplebroker.core.BrokerMain

启动了应用程序,但没有启动服务器和程序之间的任何通信。

mvn exec:exec -Dexec.mainClass=org.powertac.samplebroker.core.BrokerMain

给了我上面的错误信息。

我尝试在Spring中运行它。它没有改变任何东西。我也试过了

mvn exec:exec

这也没用。

pom:

<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>

  <artifactId>broker-core</artifactId>
  <version>1.3.3-SNAPSHOT</version>
  <description>Common core of a Power TAC broker implementation</description>
  <packaging>jar</packaging>

  <name>broker-core</name>
  <url>http://www.powertac.org</url>

  <parent>
    <groupId>org.powertac</groupId>
<artifactId>server-master</artifactId>
    <version>1.3.3-SNAPSHOT</version>
<relativePath />

</parent>
      <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>    

<active-mq.version>5.7.0</active-mq.version>
<xbean-spring.version>4.5</xbean-spring.version>
<jopt-simple.version>4.9</jopt-simple.version>
<json-lib.version>2.4</json-lib.version>
<commons-io.version>2.4</commons-io.version>

<aspectj-rt.version>1.8.7</aspectj-rt.version>
<aspectj-plugin.version>1.8</aspectj-plugin.version>
<aspectj-plugin.compliance>1.8</aspectj-plugin.compliance>

  <!-- Sonatype OSS repo for resolving snapshot modules -->
  <repositories>
    <repository>
      <id>sonatype</id>
      <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>

  <dependencies>    
<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-jms</artifactId>
  <version>${spring.version}</version>
</dependency>

    <!-- ActiveMQ -->
<dependency>    
  <groupId>org.apache.activemq</groupId>
  <artifactId>activemq-core</artifactId>
  <version>${active-mq.version}</version>
</dependency>
<dependency>    
  <groupId>org.apache.activemq</groupId>
  <artifactId>activemq-pool</artifactId>
  <version>${active-mq.version}</version>
</dependency>
<dependency>
  <groupId>org.apache.xbean</groupId>
  <artifactId>xbean-spring</artifactId>
  <version>${xbean-spring.version}</version>
</dependency>
<dependency>
  <groupId>net.sf.jopt-simple</groupId>
  <artifactId>jopt-simple</artifactId>
  <version>${jopt-simple.version}</version>
</dependency>
<dependency>   
  <groupId>net.sf.json-lib</groupId>   
  <artifactId>json-lib</artifactId>   
  <version>${json-lib.version}</version>   
  <classifier>jdk15</classifier>   
</dependency>
<dependency>   
  <groupId>commons-io</groupId>
  <artifactId>commons-io</artifactId>
  <version>${commons-io.version}</version>
</dependency>

  <build>
<finalName>broker-core</finalName>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
      <source>${maven-compiler.source}</source>
      <target>${maven-compiler.target}</target>
    </configuration>
  </plugin>
  <plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>${aspectj-plugin.version}</version>
    <executions>
      <execution>
        <goals>
          <goal>compile</goal>
          <goal>test-compile</goal>
        </goals>
        <configuration>
          <verbose>false</verbose>
          <complianceLevel>${aspectj-plugin.compliance}</complianceLevel>
          <weaveDependencies>
            <weaveDependency>
              <groupId>org.powertac</groupId>
              <artifactId>common</artifactId>
            </weaveDependency>
          </weaveDependencies>
        </configuration>
      </execution>
    </executions>
  </plugin>

      <!--  bundle sources for javadoc prep -->
  <plugin>
    <artifactId>maven-source-plugin</artifactId>
    <executions>
      <execution>
        <id>bundle-sources</id>
        <phase>package</phase>
        <goals>
          <!-- produce source artifact for main project sources -->
          <goal>jar-no-fork</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>
  </build>

  <scm>
<connection>scm:git:git//github.com/powertac/broker-core.git</connection>
<developerConnection>scm:git:git@github.com:powertac/broker-core.git</developerConnection>
<url>https://github.com/powertac</url>

1 个答案:

答案 0 :(得分:0)

如错误所示,您在mvn命令中缺少executable。您还应该按照maven usage section

中的规定将exec插件添加到插件部分

并将exec插件的配置部分更新为

        <configuration>
      <executable>java</executable>
      <arguments>
        <argument>-Dmyproperty=myvalue</argument>
        <argument>-classpath</argument>
        <!-- automatically creates the classpath using all project dependencies,
             also adding the project build directory -->
        <classpath/>
        <argument>org.powertac.samplebroker.core.BrokerMain</argument>
        ...
      </arguments>
    </configuration>

参考:http://www.mojohaus.org/exec-maven-plugin/examples/example-exec-for-java-programs.html

然后尝试mvn exec:exec -Dexec.executable="java"