使用Maven构建多模块项目Word下载.docx
- 文档编号:8510227
- 上传时间:2023-05-11
- 格式:DOCX
- 页数:14
- 大小:16.72KB
使用Maven构建多模块项目Word下载.docx
《使用Maven构建多模块项目Word下载.docx》由会员分享,可在线阅读,更多相关《使用Maven构建多模块项目Word下载.docx(14页珍藏版)》请在冰点文库上搜索。
命令执行完成之后可以看到在当前目录(C:
\DocumentsandSettings\Administrator)生成了system-parent目录,里面有一个src目录和一个pom.xml文件,
将src文件夹删除,然后修改pom.xml文件,将<
packaging>
jar<
/packaging>
修改为<
pom<
,pom表示它是一个被继承的模块,
1<
projectxmlns="
http:
//maven.apache.org/POM/4.0.0"
xmlns:
xsi="
//www.w3.org/2001/XMLSchema-instance"
2xsi:
schemaLocation="
//maven.apache.org/POM/4.0.0http:
//maven.apache.org/xsd/maven-4.0.0.xsd"
>
3<
modelVersion>
4.0.0<
/modelVersion>
4
5<
groupId>
me.gacl<
/groupId>
6<
artifactId>
system-parent<
/artifactId>
7<
version>
1.0-SNAPSHOT<
/version>
8<
9
10<
name>
/name>
11<
url>
//maven.apache.org<
/url>
12
13<
properties>
14<
project.build.sourceEncoding>
UTF-8<
/project.build.sourceEncoding>
15<
/properties>
16
17<
dependencies>
18<
dependency>
19<
junit<
20<
21<
3.8.1<
22<
scope>
test<
/scope>
23<
/dependency>
24<
/dependencies>
25<
/project>
复制代码
二、创建sytem-domain模块
在命令行进入创建好的system-parent目录,然后执行下列命令:
create-DgroupId=me.gacl-DartifactId=system-domain-DarchetypeArtifactId=maven-archetype-quickstart-DinteractiveMode=false
命令执行完成之后可以看到在system-parent目录中生成了system-domain,里面包含src目录和pom.xml文件。
同时,在system-parent目录中的pom.xml文件自动添加
<
modules>
<
module>
system-domain<
/module>
/modules>
这时,system-parent的pom.xml文件如下:
?
xmlversion="
1.0"
encoding="
UTF-8"
2<
xsi:
26<
27<
28<
修改system-domain目录中的pom.xml文件,把<
和<
去掉,加上<
,因为groupId和version会继承system-parent中的groupId和version,packaging设置打包方式为jar
projectxsi:
xmlns="
3xmlns:
4<
parent>
9<
/parent>
10
12<
13
16<
三、创建sytem-dao模块
create-DgroupId=me.gacl-DartifactId=system-dao-DarchetypeArtifactId=maven-archetype-quickstart-DinteractiveMode=false
命令执行完成之后可以看到在system-parent目录中生成了system-dao,里面包含src目录和pom.xml文件。
同时,在system-parent目录中的pom.xml文件自动变成
http:
system-dao<
29<
修改system-dao目录中的pom.xml文件,,把<
,因为groupId和version会继承system-parent中的groupId和version,packaging设置打包方式为jar,同时添加对system-domain模块的依赖,修改后的内容如下:
!
--system-dao需要使用到system-domain中的类,所以需要添加对system-domain模块的依赖-->
${project.version}<
四、创建system-service模块
create-DgroupId=me.gacl-DartifactId=system-service-DarchetypeArtifactId=maven-archetype-quickstart-DinteractiveMode=false
如下图所示:
命令执行完成之后可以看到在system-parent目录中生成了system-service,里面包含src目录和pom.xml文件。
system-service<
30<
修改system-service目录中的pom.xml文件,,把<
,因为groupId和version会继承system-parent中的groupId和version,packaging设置打包方式为jar,同时添加对system-dao模块的依赖,system-service依赖system-dao和system-domain,但是我们只需添加system-dao的依赖即可,因为system-dao已经依赖了system-domain。
--
21system-service依赖system-dao和system-domain,
22但是我们只需添加system-dao的依赖即可,因为system-dao已经依赖了system-domain
23-->
五、创建system-web模块
create-DgroupId=me.gacl-DartifactId=system-web-DarchetypeArtifactId=maven-archetype-webapp-DinteractiveMode=false
命令执行完成之后可以看到在system-parent目录中生成了system-web,里面包含src目录和pom.xml文件。
如下图所示:
在\system-web\src\main\webapp目录中还生成了一个简单的index.jsp,如<
html>
body>
h2>
HelloWorld!
/h2>
/body>
/html>
system-web\src\main\webapp\WEB-INF目录中生成了web.xml
21
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 使用 Maven 构建 模块 项目