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

生成jar

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

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

"D:\Program Files\Java\JDK\jdk1.8.0_31\bin\java" "-Dmaven.home=D:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=D:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.2\plugins\maven\lib\maven3\bin\m2.conf" -Didea.launcher.port=7535 "-Didea.launcher.bin.path=D:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.2\bin" -Dfile.encoding=GBK -classpath "D:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.4.jar;D:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.2\lib\idea_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:\JavaWorkSpace\oxgren\oxgren-common\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] Unable to locate the Javac Compiler in:
  D:\Program Files\Java\JDK\jdk1.8.0_31\..\lib\tools.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 Files\Java\JDK\jdk1.8.0_31\..\lib\tools.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 Files\Java\JDK\jdk1.8.0_31\bin\java" "-Dmaven.home=D:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.2\plugins\maven\lib\maven3" "-Dclassworlds.conf=D:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.2\plugins\maven\lib\maven3\bin\m2.conf" -Didea.launcher.port=7537 "-Didea.launcher.bin.path=D:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.2\bin" -Dfile.encoding=GBK -classpath "D:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.2\plugins\maven\lib\maven3\boot\plexus-classworlds-2.4.jar;D:\Program Files (x86)\JetBrains\IntelliJ IDEA 14.1.2\lib\idea_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:\JavaWorkSpace\oxgren\oxgren-common\src\test\resources
[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:\JavaWorkSpace\oxgren\oxgren-common\target\surefire-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:\JavaWorkSpace\oxgren\oxgren-common\target\oxgren-common-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.3.1:install (default-install) @ oxgren-common ---
[INFO] Installing D:\JavaWorkSpace\oxgren\oxgren-common\target\oxgren-common-1.0-SNAPSHOT.jar to C:\Users\yuchao\.m2\repository\oxgren\oxgren-common\1.0-SNAPSHOT\oxgren-common-1.0-SNAPSHOT.jar
[INFO] Installing D:\JavaWorkSpace\oxgren\oxgren-common\pom.xml to C:\Users\yuchao\.m2\repository\oxgren\oxgren-common\1.0-SNAPSHOT\oxgren-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

时间: 2024-10-19 20:20:26

【maven项目结构】module 生成独立的jar的相关文章

Maven01 环境准备、maven项目结构、编译/测试/打包/清除、安装、

0 前提准备 0.1 安装java开发环境 0.2 安装maven工具 1 maven项目基本结构 如图所示,整个maven项目有业务文件.测试文件.POM依赖管理文件:其实还有一个资源文件resources: 代码文件和测试文件都是放在src文件中,src文件成为源文件:业务文件和测试文件处于src中同一级目录: 资源文件管理文件分为测试资源文件和业务资源文件,分别位于main目录和test目录,此处没有进行创建. 2 maven项目搭建 2.1 创建maven项目结构 安装maven规范的目

Maven项目编译时报错缺少tools.jar

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project ERP: Compilation failure [ERROR] Unable to locate the Javac Compiler in: [ERROR] C:\Program Files\Java\jre7\..\lib\tools.jar [ERR

maven项目结构

maven java项目结构 pom.xml 核心配置,项目根下 src/main/java java源码目录 src/main/resources java配置文件目录(maven项目中的配置文件以后都放到这里) src/test/java 测试源码目录 src/test/resources 测试配置目录 target 输出目录(字节码文件和jar包)//编译自动生成 maven web项目结构 pom.xml 核心配置 src/main/java java源码 src/main/resour

Eclipse下maven项目自动打war包丢失jar包问题解决方法

以前用Eclipse测试maven 的web工程,在eclipse内部tomcat右键上点一下"clean"就可以把工作空间的web项目代码自动发布到"F:\IWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps"这个路径,十分的方便.如果tomcat里部署的war包选择的是"Add External Web Module"的话,那测试的话,就要哭了.每次

maven项目打包时生成dependency-reduced-pom.xml

今天给maven项目打jar包,发现在pom.xml文件的同路径下,突然生出了一个dependency-reduced-pom.xml,也不知道这个文件是干什么的,看着别扭就想着删除了它. 后来知道是我在pom.xml中,使用了maven-shade-plugin插件打jar包,才导致了它的出现.添加上以下代码可以避免生成此文件:<configuration>      <createDependencyReducedPom>false</createDependencyRe

maven(三):maven项目结构及其运行机制

在上一篇中讲了如何创建maven项目,现在回到那个项目 项目结构 src/main/java:java代码目录 src/main/resources:资源目录,比如spring.xml文件,properties参数等 java和resources目录的内容都会编译到classpath下,也就是和传统项目的src目录一样的作用,这里分成多个目录是为了开发时方便管理资源 libraries:默认只有jre和maven,没有引入tomcat库,我们的项目应该可以在所有的web服务器中运行,而不仅仅是t

maven项目打包成可执行的jar

编写功能类:   编写main方法类:   在pom文件中配置:   打包方式: 1.进入到项目所在目录,例如: cd D:\workspace\riskCompensate\FileToZkUtil 2.运行命令 mvn assembly:assembly 3.在项目的target目录中可以看到如下文件 说明打包完成. 运行方式: 1.在cmd命令窗口进入target目录 cd  cd D:\workspace\riskCompensate\FileToZkUtil\target 2.输入 j

20) maven 项目结构:all in one

这是最常见的项目结构 垂直结构 也是初学者常用的 也是小项目常用的 优点 全部代码在一个项目里,一目了然. 结构简单易于理解 一开始时小巧 缺点 随之而来的缺点也十分明显 前端项目,后端项目,接口项目等 多项目之间没有共用的代码,代码将被各种复制粘贴,越来越难维护 难于大型化分布式 高耦合

19) maven 项目结构:聚集

Project Aggregation [,æɡr?'ɡe???n] https://maven.apache.org/guides/introduction/introduction-to-the-pom.html https://maven.apache.org/guides/mini/guide-multiple-modules.html 模块式开发(将所有模块聚合在一个父pom) 使用一个父pom,管理各个模块,控制模块间依赖关系和构建顺序 开始一个简单的demo来理解这个结构 1.创建