无法在项目 mavenproject2 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (默认):
Posted
技术标签:
【中文标题】无法在项目 mavenproject2 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (默认):【英文标题】:Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (default) on project mavenproject2: 【发布时间】:2016-10-05 07:44:34 【问题描述】:我开始尝试在 Java 中使用 Vert.x。 IDE 是 Netbeans 8.1 版。 Vert.x 是 3.0.0 版。该项目的代码如下所示。 pom.xml 文件也在下面列出。此代码将在 Netbeans IDE 中运行,但如果没有下面的 BUILD REPORT 中显示的错误,构建(对于 jar 文件)将无法完成。因此,生成的 jar 文件将不会执行。我已经研究了我可以在互联网上找到的所有资源,但找不到足够的解决方案/答案。任何人都可以提供任何帮助来解决此问题,我将不胜感激。
创建新项目时,Netbeans IDE 会生成 POM 文件: 文件 - 新项目 - Maven - 来自 Archetype 的项目 - vertx-java-archetype 然后我添加了 main() 方法。
详细的构建错误报告:
--- maven-jar-plugin:2.3.2:jar (default-jar) @ mavenproject2 ---
Building jar: C:\Projects\GenMatchJ\mavenproject2\target\mavenproject2-1.0-SNAPSHOT.jar
--- maven-shade-plugin:2.3:shade (default) @ mavenproject2 ---
Including io.vertx:vertx-core:jar:3.0.0 in the shaded jar.
Including io.netty:netty-common:jar:4.0.28.Final in the shaded jar.
Including io.netty:netty-buffer:jar:4.0.28.Final in the shaded jar.
Including io.netty:netty-transport:jar:4.0.28.Final in the shaded jar.
Including io.netty:netty-handler:jar:4.0.28.Final in the shaded jar.
Including io.netty:netty-codec:jar:4.0.28.Final in the shaded jar.
Including io.netty:netty-codec-http:jar:4.0.28.Final in the shaded jar.
Including com.fasterxml.jackson.core:jackson-core:jar:2.5.3 in the shaded jar.
Including com.fasterxml.jackson.core:jackson-databind:jar:2.5.3 in the shaded jar.
Including com.fasterxml.jackson.core:jackson-annotations:jar:2.5.0 in the shaded jar.
Including io.vertx:vertx-web:jar:3.0.0 in the shaded jar.
Including io.vertx:vertx-auth-common:jar:3.0.0 in the shaded jar.
--- exec-maven-plugin:1.3.2:exec (default) @ mavenproject2 ---
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 3.290s
Finished at: Sun Jun 05 13:01:40 EDT 2016
Final Memory: 30M/313M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (default) on project mavenproject2: The parameters 'executable' for goal org.codehaus.mojo:exec-maven-plugin:1.3.2:exec are missing or invalid -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
POM.XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>com.ssp</groupId>
<artifactId>mavenproject2</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-dependencies</artifactId>
<version>3.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>io.vertx.core.Starter</Main-Class>
<Main-Verticle>com.ssp.mavenproject2.Main</Main-Verticle>
</manifestEntries>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/services/io.vertx.core.spi.VerticleFactory</resource>
</transformer>
</transformers>
<artifactSet></artifactSet>
<outputFile>$project.build.directory/mavenproject2-$project.version-fat.jar</outputFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>io.vertx.core.Starter</mainClass>
<additionalClasspathElements>
<additionalClasspathElement>$basedir/src/main/java/</additionalClasspathElement>
</additionalClasspathElements>
<systemProperties>
<systemProperty>
<key>vertx.deployment.options.redeploy</key>
<value>true</value>
</systemProperty>
<systemProperty>
<key>vertx.deployment.options.redeployScanPeriod</key>
<value>100</value>
</systemProperty>
</systemProperties>
<arguments>
<argument>run</argument>
<argument>com/ssp/mavenproject2/Main.java</argument>
<!-- <argument>-cluster</argument>
<argument>-cluster-host</argument>
<argument>127.0.0.1</argument>-->
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<name>MainSsp</name>
<description>Main entry point for SSP Example with embedded Vert.x</description>
</project>
源代码:
package com.ssp.mavenproject2;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Vertx;
import javax.swing.JOptionPane;
/**
*
*/
public class Main extends AbstractVerticle
public static void main(String[] args)
JOptionPane.showMessageDialog(null, "This Vert.x/Java integration is UUUGGGGHH tough without documentation...");
// Create an HTTP server which simply returns "Hello World!" to each request.
Vertx.vertx().createHttpServer().requestHandler(req -> req.response().end("Hello World!")).listen(8080);
Vertx.vertx().setPeriodic(3000, res ->
System.out.println("Periodic event triggered.");
);
try
Thread.sleep(30000);
catch(Exception e)
System.out.println("Exception caught");
@Override
public void start() throws Exception
vertx.setPeriodic(3000, res ->
System.out.println("Periodic event triggered.");
);
【问题讨论】:
【参考方案1】:看起来您正在尝试运行mvn exec:exec
,但为此您需要指定可执行文件(您遇到的错误)。在这种情况下,可执行文件应该是您的 java 二进制文件,例如:/usr/java/latest/bin/java
如果您使用的是 linux 和 Oracle RPM。
或者你应该这样做:mvn exec:java
,它知道可执行文件是java
,并且知道如何从 pom 文件中选择类路径依赖项。
现在,如果您注意您的代码,您会发现从未调用过 public static void main
方法,您的 exec 插件使用 vert.x 启动器而不是您的类,因此当您的应用启动时不会有任何服务器,只是在start
方法中执行的周期性代码。
如果你执行你的main,那么你仍然缺少部署你的verticle,所以你有服务器但没有定期任务,为了实现你需要添加:
vertx.deployVerticle(Main.class.getName());
【讨论】:
将 '允许 Netbeans 索引 maven 存储库
~\.m2\repository\org\codehaus\mojo
在存储库被编入索引后,一切都应该正常工作。
【讨论】:
以上是关于无法在项目 mavenproject2 上执行目标 org.codehaus.mojo:exec-maven-plugin:1.3.2:exec (默认):的主要内容,如果未能解决你的问题,请参考以下文章
无法执行目标org.apache.maven.plugins:maven-deploy-plugin:2.7:在项目上部署default-deploy
无法在项目上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:testCompile (default-testCompile)
无法在项目 fhirql 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile):致命
Maven 构建编译错误:无法在项目 Maven 上执行目标 org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-c
无法在项目上执行目标 org.apache.maven.plugins:maven-compiler-plugin (default-compile):致命错误编译:未找到 tools.jar
无法在项目 jraft 上执行目标 org.sonarsource.scanner.maven:sonar-maven-plugin:3.3.0.603:sonar (default-cli):没有治