maven 聚合工程的创建和打包
---恢复内容开始---
使用eclipse创建maven项目
第一步:创建父工程hg-parent,如图;
右击空白处,new创建新maven工程:
搜索maven项目
父工程使用pom打包方式
第二步:创建子工程
右击父工程,创建maven module工程:
定义子工程,这里是以表现层为例,是web工程,所以打包方式为war,如果是其他非web工程就可以打包成jar,这一点需要注意。
如果出现如下错误
在学习maven模块化构建项目的时候遇到了如下报错信息:
web.xml is missing and <failOnMissingWebXml> is set to true
。这时候需要右击项目——>Java EE Tools——>Generate Deployment Descriptor Stub.然后系统会在src/main/webapp/WEB_INF文件加下创建web.xml文件。错误解决!
完成后的目录结构
父工程的pom.xml
子工程pom.xml文件内容:
最后一步,打包项目
右键父工程,
运行时出错了,暂未解决,,解决后再修改
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] Child module D:\eclipse-workspace\hg-parent1\hg-parent-web of D:\eclipse-workspace\hg-parent1\pom.xml does not exist @
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project com.hg:hg-parent1:0.0.1-SNAPSHOT (D:\eclipse-workspace\hg-parent1\pom.xml) has 1 error
[ERROR] Child module D:\eclipse-workspace\hg-parent1\hg-parent-web of D:\eclipse-workspace\hg-parent1\pom.xml does not exist
[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/ProjectBuildingException
注:本人正在学习中,还没调试成功,望牛人指点.项目中各种配置都没写还.
---恢复内容结束---