新手学习Maven子模块
来源:互联网 发布:java导出excel并下载 编辑:程序博客网 时间:2024/05/16 19:15
此前对maven的认识不多,最近得知maven对jar包的依赖以及源码的管理非常方便,所以也就开始使用maven了。
不过此时对maven的使用也仅限于maven对jar包的管理,其它功能使用得比不多。
近两天听说maven有个一子模块的功能,可以把一个项目分成不同的子项目来处理,并行开发,觉得这个功能非常实用,所以也想学习一下。
我一共新建了3个项目testP、testC1和testC2
---- testP | -- pom.xml (packaging: pom) | -- testC2 | -- pom.xml (packaging: jar) | -- testC1 | -- pom.xml (packaging: war)
testP的pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.lee.test</groupId><artifactId>testP</artifactId><packaging>pom</packaging><version>0.0.1-SNAPSHOT</version><name>testP Maven Webapp</name><url>http://maven.apache.org</url><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>3.8.1</version><scope>test</scope></dependency></dependencies><build><finalName>testP</finalName></build><modules><module>testC2</module><module>testC1</module></modules><properties><!-- project character encoding setting --><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><!-- java source version --><maven.compiler.source>1.6</maven.compiler.source><!-- java class version --><maven.compiler.target>1.6</maven.compiler.target></properties></project>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><modelVersion>4.0.0</modelVersion><parent><groupId>com.lee.test</groupId><artifactId>testP</artifactId><version>0.0.1-SNAPSHOT</version></parent><groupId>com.lee.test</groupId><artifactId>testC1</artifactId><version>0.0.1-SNAPSHOT</version><packaging>war</packaging><name>testC2 Maven Webapp</name><url>http://maven.apache.org</url><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>3.8.1</version><scope>test</scope></dependency></dependencies><build><finalName>testC2</finalName></build><properties><!-- project character encoding setting --><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><!-- java source version --><maven.compiler.source>1.6</maven.compiler.source><!-- java class version --><maven.compiler.target>1.6</maven.compiler.target></properties></project>
testC2的pom.xml
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><modelVersion>4.0.0</modelVersion><parent><groupId>com.lee.test</groupId><artifactId>testP</artifactId><version>0.0.1-SNAPSHOT</version></parent><groupId>com.lee.test</groupId><artifactId>testC2</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>testC2 Maven Webapp</name><url>http://maven.apache.org</url><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>3.8.1</version><scope>test</scope></dependency></dependencies><build><finalName>testC2</finalName></build><properties><!-- project character encoding setting --><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><!-- java source version --><maven.compiler.source>1.6</maven.compiler.source><!-- java class version --><maven.compiler.target>1.6</maven.compiler.target></properties></project>
对于个人而言,有点代码洁癖,所以会觉得testP这个项目有点别扭。它目录下的pom.xml文件以及其packaging的值为pom也感到不解。
觉得应该可以直接在testC1目录下,即pom.xml的packaging值为war值的项目下引入其它子模块就够了。可是自己尝试修改过几次,pom.xml文件都会报错。
总而言之,maven子模块的框架算是依葫芦画瓢地弄出来了,但是对齐原理以及为何这样设计仍旧是知之甚少。还希望有懂的maven子项目的朋友多多发言,教教小弟,小弟不甚感激!
0 0
- 新手学习Maven子模块
- 新建maven子模块详细步骤
- Eclipse创建Maven工程及子模块
- Maven更新子模块的版本号
- maven 自动更新子模块的依赖版本号
- 子模块
- 【maven】多子模块maven模板工程archetype创建过程
- 新建maven子模块 出现 Unable to read parent POM
- 如何使用eclipse创建Maven工程及其子模块
- 使用 eclipse 创建 Maven 工程及其子模块
- Eclipse maven 导入父模块和子模块
- Maven实战(六)--子模块的聚合和继承
- 【Maven】子模块打包失败 pom.xml is not existed
- Maven实战(六)--子模块的聚合和继承
- maven工程中找不到子模块spring配置文件的解决办法
- maven模块的子模块受损-恢复方案
- maven项目 子模块的myabtis配置文件读取失败
- Eclipse中将子模块项目转换为Maven Project
- 【LeetCode】Find Minimum in Rotated Sorted Array 解题报告
- Distinct subsequence
- 第八周 项目五 定期存款利息计算器
- graycomatrix 计算(图像)灰度共生矩阵(CLCM)——matlab相关函数说明,很详细
- Connect To Oracle DB Via JDBC Driver
- 新手学习Maven子模块
- BPM Process Instances – Faults, Rollback & Recovery – Part 2
- 面向对象软件工程概念模型
- 行了!!!!
- ubuntu 下命令行播放器mplayer 使用详解
- 批量修改文件名
- 用lazarus开发Linux daemon程序及编写启动脚步
- BPM Process Instances – Faults, Rollback & Recovery – Part 3
- linux C语言 select函数的用法