[英]Maven multi module
I have created two modules in my project.It was compiled but not executed properly.so help me anyone to fix the issue. 我在项目中创建了两个模块,虽然已编译但未正确执行,所以请任何人帮助我解决问题。 Here I present my complete error log also. 在这里,我还提供了完整的错误日志。 Error Log: 错误日志:
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
This is not related to maven multi module nature. 这与Maven多模块性质无关。 You are probably running plugin before compiling. 您可能在编译之前正在运行插件。 Ensure you define the following, 确保定义以下内容,
<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>
and before running plugin, do following, 在运行插件之前,请先执行以下操作,
mvn clean install
and then mvn exec:java
or like you doing it through command line. mvn clean install
,然后mvn exec:java
或像您通过命令行那样执行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.