Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Maven多模块_Java_Eclipse_Maven - Fatal编程技术网

Java Maven多模块

Java Maven多模块,java,eclipse,maven,Java,Eclipse,Maven,我在我的项目中创建了两个模块。它已编译但未正确执行。因此,请帮助我解决问题。在这里,我还提供了完整的错误日志。 错误日志: C:\workspace\multimaven>mvn exec:java -Dexec.mainClass="com.multimaven.module2.DerivedClass" [INFO] Scanning for projects... [INFO] -----------------------------------------------------

我在我的项目中创建了两个模块。它已编译但未正确执行。因此,请帮助我解决问题。在这里,我还提供了完整的错误日志。 错误日志:

C:\workspace\multimaven>mvn exec:java -Dexec.mainClass="com.multimaven.module2.DerivedClass"
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] multimaven
[INFO] module1
[INFO] module2
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building multimaven 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- exec-maven-plugin:1.6.0:java (default-cli) @ multimaven ---
[WARNING]
java.lang.ClassNotFoundException: com.multimaven.module2.DerivedClass
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        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:270)
        at java.lang.Thread.run(Thread.java:745)
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] multimaven ......................................... FAILURE [  0.375 s]
[INFO] module1 ............................................ SKIPPED
[INFO] module2 ............................................ SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.734 s
[INFO] Finished at: 2017-04-12T12:56:43+05:30
[INFO] Final Memory: 9M/153M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java (default-cli) on project multimaven: An exception occured while executing the Java class. com.multimaven.module2.DerivedClass -> [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/MojoExecutionException

这与maven的多模块性质无关。在编译之前,您可能正在运行插件。确保您定义了以下内容:

<plugin>
     <groupId>org.codehaus.mojo</groupId>
     <artifactId>exec-maven-plugin</artifactId>
     <version>1.2.1</version>
     <configuration>                 
         <mainClass>com.multimaven.module2.DerivedClass</mainClass>
     </configuration>
</plugin>

org.codehaus.mojo
execmaven插件
1.2.1
com.multimaven.module2.DerivedClass
在运行插件之前,请执行以下操作:

mvn clean install
然后
mvn exec:java
或者像您这样通过命令行来完成