具有限定名称的Java Maven exec-maven-plugin ClassNotFoundException

时间:2016-03-24 01:05:04

标签: java eclipse maven

我正在使用Amazons DynamoDB进行实验,并正在使用Maven和eclipse。我试图运行我的程序并继续运行ClassNotFound exeption。我的项目层次结构是实验 - > src - > DynamoDBLoad.java没有包(它在导入时自动设置为Maven项目)。

mvn clean install org.codehaus.mojo:exec-maven-plugin:1.1.1:java -Dexec.mainClass="experiment.src.DynamoDBLoad.java" -e

我在运行配置的目标部分使用此行而没有mvn前缀。我也尝试过DynamoDBLoad和src.DynamoDBLoad。有谁知道为什么我不能让它运行?

*编辑StackTrace

[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1.1:java (default) on project experiment: An exception occured while executing the Java class. DynamoDBLoad -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.1.1:java (default) on project experiment: An exception occured while executing the Java class. DynamoDBLoad
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(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
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. DynamoDBLoad
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:338)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 more
Caused by: java.lang.ClassNotFoundException: DynamoDBLoad
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:276)
at java.lang.Thread.run(Thread.java:745)

1 个答案:

答案 0 :(得分:0)

也许将.java放在mvn命令上:

更改

mvn clean install org.codehaus.mojo:exec-maven-plugin:1.1.1:java -Dexec.mainClass="experiment.src.DynamoDBLoad.java" -e

mvn clean install org.codehaus.mojo:exec-maven-plugin:1.1.1:java -Dexec.mainClass="experiment.src.DynamoDBLoad" -e

另外,如果mainClass是experiment.src.DynamoDBLoad,那么源文件DynamoDBLoad.java应该在src / main / java / experiment / src ...