java - java Maven 無法執行目標: exec Maven 插件:1.3

  显示原文与译文双语对照的内容
75 1

我使用 Maven 編譯 Jersey Web服務 項目,在 Windows 2008伺服器上編譯時遇到錯誤。

以下是錯誤:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:UsersAdministratorDocumentsMyApplication>mvn -e exec:java
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBu
ilder with a thread count of 1
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MyApplication 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.3:java (default-cli) @ MyApplication ---
[WARNING] Warning: killAfter is now deprecated. Do you need it? Please comment on MEXEC-6.
[WARNING]
java.lang.ClassNotFoundException: rb.resource.Main
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:281)
 at java.lang.Thread.run(Unknown Source)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.244 s
[INFO] Finished at: 2014-05-31T12:20:54+08:00
[INFO] Final Memory: 12M/91M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.3:java (default-cli) on project
 MyApplication: An exception occured while executing the Java class. rb.resource.Main -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exe
c-maven-plugin:1.3:java (default-cli) on project MyApplication: An exception occured while executi
ng the Java class. rb.resource.Main
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBu
ilder.java:108)
 at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBu
ilder.java:76)
 at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(Si
ngleThreadedBuilder.java:51)
 at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
 at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
 at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
 at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
 at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
 at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
 at java.lang.reflect.Method.invoke(Unknown Source)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
 at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
 at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
 at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the
Java class. rb.resource.Main
 at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:345)
 at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.j
ava:133)
 at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
. . . 19 more
Caused by: java.lang.ClassNotFoundException: rb.resource.Main
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:281)
 at java.lang.Thread.run(Unknown Source)
[ERROR]
[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 arti
cles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
C:UsersAdministratorDocumentsMyApplication>

以下是我的Maven 和java版本:

Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-15T01:37:52+08:00)
Maven home: C:apache-maven-3.2.1bin..
Java version: 1.8.0_05, vendor: Oracle Corporation
Java home: c:Progra~1Javajre8
Default locale: en_SG, platform encoding: Cp1252
OS name:"windows server 2008 r2", version:"6.1", arch:"amd64", family:"dos"

下面是我在 Windows 2008中的pom.xml的內容。pom.xml 內容略有不同。( 比如: java版本,:

<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/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>org.company</groupId>
 <artifactId>MyApplication</artifactId>
 <packaging>jar</packaging>
 <version>1.0-SNAPSHOT</version>
 <name>MyApplication</name>
 <dependencyManagement>
 <dependencies>
 <dependency>
 <groupId>org.glassfish.jersey</groupId>
 <artifactId>jersey-bom</artifactId>
 <version>${jersey.version}</version>
 <type>pom</type>
 <scope>import</scope>
 </dependency>
 </dependencies>
 </dependencyManagement>
 <dependencies>
 <dependency>
 <groupId>org.glassfish.jersey.containers</groupId>
 <artifactId>jersey-container-grizzly2-http</artifactId>
 </dependency>
 <!-- uncomment this to get JSON support:
 <dependency>
 <groupId>org.glassfish.jersey.media</groupId>
 <artifactId>jersey-media-moxy</artifactId>
 </dependency>
 -->
 <dependency>
 <groupId>junit</groupId>
 <artifactId>junit</artifactId>
 <version>4.9</version>
 <scope>test</scope>
 </dependency>
 <!-- Gson: Java to Json conversion -->
 <dependency>
 <groupId>com.google.code.gson</groupId>
 <artifactId>gson</artifactId>
 <version>2.2.4</version>
 <scope>compile</scope>
 </dependency>
 <dependency>
 <groupId>mysql</groupId>
 <artifactId>mysql-connector-java</artifactId>
 <version>5.1.6</version>
 </dependency>
 <!-- Apache Log4J -->
 <dependency>
 <groupId>log4j</groupId>
 <artifactId>log4j</artifactId>
 <version>1.2.17</version>
 </dependency>
 </dependencies>
 <build>
 <plugins>
 <plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-compiler-plugin</artifactId>
 <version>3.1</version>
 <inherited>true</inherited>
 <configuration>
 <source>1.8</source>
 <target>1.8</target>
 <archive>
 <manifest>
 <addClasspath>true</addClasspath>
 <classpathPrefix>lib</classpathPrefix>
 <mainClass>org.company.Main</mainClass>
 </manifest>
 </archive>
 </configuration>
 </plugin>
 <plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>exec-maven-plugin</artifactId>
 <version>1.3</version>
 <executions>
 <execution>
 <goals>
 <goal>java</goal>
 </goals>
 </execution>
 </executions>
 <configuration>
 <mainClass>org.company.Main</mainClass>
 </configuration>
 </plugin>
 </plugins>
 </build>
 <properties>
 <jersey.version>2.7</jersey.version>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 </properties>
</project>
时间:原作者:0个回答

...