我将一个java项目转换为maven项目,它构建和清理就好了,但是当我尝试使用mvn exec:java运行它时,我收到以下错误:
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java (default-cli) on project ExcelPublicationService: The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java are missing or invalid -> [Help 1]
我的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>
<groupId>ExcelPublicationService</groupId>
<artifactId>ExcelPublicationService</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<mainClass>bns.gwt.dpm.service.rest.main.DynamicUdfPublicationServer</mainClass>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-multipart</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.glassfish.grizzly</groupId>
<artifactId>grizzly-http-server</artifactId>
<version>2.3.8</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-grizzly2-http</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-sse</artifactId>
<version>2.5.1</version>
</dependency>
</dependencies>
主要课程位于: SRC \主\的java \ BNS \ GWT \ DPM \服务\其余\主
它叫做DynamicUdfPublicationServer.java
并有一个包名:
package bns.gwt.dpm.service.rest.main
源文件位于:
ExcelPublicationService/src/main/java
和maven将类编译为:
ExcelPublicationService\target\classes
答案 0 :(得分:0)
您必须使用exec-maven-plugin作为exec:java目标。请参阅插件使用情况here
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.4.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<mainClass>bns.gwt.dpm.service.rest.main.DynamicUdfPublicationServer</mainClass>
<cleanupDaemonThreads>false</cleanupDaemonThreads>
</configuration>
</plugin>
</plugins>
</build>
请注意,您不需要<pluginManagement>... <pluginManagement/>
个标签。
或
从命令行,您必须执行
mvn exec:java -Dexec.mainClass="bns.gwt.dpm.service.rest.main.DynamicUdfPublicationServer"