【maven项目结构】module 生成独立的jar

生成jar

生成jar的过程会出现以下问题:

clean完了之后就会出现以下问题:

"D:Program FilesJavaJDKjdk1.8.0_31injava" "-Dmaven.home=D:Program Files (x86)JetBrainsIntelliJ IDEA 14.1.2pluginsmavenlibmaven3" "-Dclassworlds.conf=D:Program Files (x86)JetBrainsIntelliJ IDEA 14.1.2pluginsmavenlibmaven3inm2.conf" -Didea.launcher.port=7535 "-Didea.launcher.bin.path=D:Program Files (x86)JetBrainsIntelliJ IDEA 14.1.2in" -Dfile.encoding=GBK -classpath "D:Program Files (x86)JetBrainsIntelliJ IDEA 14.1.2pluginsmavenlibmaven3ootplexus-classworlds-2.4.jar;D:Program Files (x86)JetBrainsIntelliJ IDEA 14.1.2libidea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=14.1.2 install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building oxgren-common 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ oxgren-common ---
[debug] execute contextualize
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ oxgren-common ---
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 5 source files to D:JavaWorkSpaceoxgrenoxgren-common	argetclasses
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
  D:Program FilesJavaJDKjdk1.8.0_31..lib	ools.jar
Please ensure you are using JDK 1.4 or above and
not a JRE (the com.sun.tools.javac.Main class is required).
In most cases you can change the location of your Java
installation by setting the JAVA_HOME environment variable.
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.114s
[INFO] Finished at: Mon Sep 07 20:06:03 CST 2015
[INFO] Final Memory: 7M/164M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project oxgren-common: Compilation failure
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] D:Program FilesJavaJDKjdk1.8.0_31..lib	ools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
[ERROR] -> [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/MojoFailureException

Process finished with exit code 1

在目录上compile module  再去  install 就可以生成jar包了

jre找不到  不关心这么多了 ,正确的如下

"D:Program FilesJavaJDKjdk1.8.0_31injava" "-Dmaven.home=D:Program Files (x86)JetBrainsIntelliJ IDEA 14.1.2pluginsmavenlibmaven3" "-Dclassworlds.conf=D:Program Files (x86)JetBrainsIntelliJ IDEA 14.1.2pluginsmavenlibmaven3inm2.conf" -Didea.launcher.port=7537 "-Didea.launcher.bin.path=D:Program Files (x86)JetBrainsIntelliJ IDEA 14.1.2in" -Dfile.encoding=GBK -classpath "D:Program Files (x86)JetBrainsIntelliJ IDEA 14.1.2pluginsmavenlibmaven3ootplexus-classworlds-2.4.jar;D:Program Files (x86)JetBrainsIntelliJ IDEA 14.1.2libidea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.classworlds.Launcher -Didea.version=14.1.2 install
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building oxgren-common 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ oxgren-common ---
[debug] execute contextualize
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ oxgren-common ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ oxgren-common ---
[debug] execute contextualize
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:JavaWorkSpaceoxgrenoxgren-commonsrc	est
esources
[INFO] 
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ oxgren-common ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.10:test (default-test) @ oxgren-common ---
[INFO] Surefire report directory: D:JavaWorkSpaceoxgrenoxgren-common	argetsurefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running Base64HanderTest
encodeStr:6L+b5YWlamF2YeeahOS4lueVjA==
urlEncodeStr:6L-b5YWlamF2YeeahOS4lueVjA==
mimeEncodeStr:6L+b5YWlamF2YeeahOS4lueVjA==
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.094 sec
Running WithAttachmentMessageTest
发送邮件
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.125 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ oxgren-common ---
[INFO] Building jar: D:JavaWorkSpaceoxgrenoxgren-common	argetoxgren-common-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ oxgren-common ---
[INFO] Installing D:JavaWorkSpaceoxgrenoxgren-common	argetoxgren-common-1.0-SNAPSHOT.jar to C:Usersyuchao.m2
epositoryoxgrenoxgren-common1.0-SNAPSHOToxgren-common-1.0-SNAPSHOT.jar
[INFO] Installing D:JavaWorkSpaceoxgrenoxgren-commonpom.xml to C:Usersyuchao.m2
epositoryoxgrenoxgren-common1.0-SNAPSHOToxgren-common-1.0-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.785s
[INFO] Finished at: Mon Sep 07 20:23:45 CST 2015
[INFO] Final Memory: 9M/164M
[INFO] ------------------------------------------------------------------------

Process finished with exit code 0

如果test存在不通过的内容,也无法完成jar

原文地址:https://www.cnblogs.com/viewcozy/p/4789877.html