Maven学习  --- <parent>

本文介绍了Maven多模块项目的配置方式,详细解释了父模块与子模块之间的关系及配置方法,并列举了子模块可以从父模块继承的多种元素。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.由于maven的多模块聚合结构,父模块的<modules>记录着所有的子模块,在每一个子模块中也都标明了自己的父模块的配置信息.例如
  • qmxbb-platform为父模块  
  • webapps为子模块
  • 父模块的<modules>中记录了子模块的artifactId
  • 子模块中<parent>也记录着父模块的配置信息
  • 子模块中<parent>中的<relativePath>中记录的是父项目相对于子项目的路径.这样的逻辑是,在构建子项目的时候首先根据相对路径找到父项目
  • 示例

    • 父模块
        
    • 子模块



2.子模块可从父模块继承的元素
  1. groupId项目组ID,项目坐标的核心元素
  2. version项目版本,项目坐标的核心元素
  3. description项目的描述信息
  4. organization项目的组织信息
  5. inceptionYear项目的创始年份
  6. url项目的URL地址
  7. developers项目的开发者信息
  8. contributors项目的贡献者信息
  9. distributionManagement项目的部署信息
  10. issueManagement项目的缺陷跟踪系统信息
  11. ciManagement项目的持续集成系统信息
  12. scm项目的版本控制系统信息
  13. mailingLists项目的邮件列表信息
  14. properties项目的依赖配置
  15. dependencies项目的依赖配置
  16. dependencyManagement:项目的依赖管理配置
  17. repositories项目的仓库配置
  18. build包括项目的源码目录配置、输出目录配置、插件配置、插件管理配置等
  19. reporting包括项目的报告输出目录配置、报告插件配置等






<?xml version="1.0" encoding="UTF-8"?> <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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>springMybatis</artifactId> <version>1.0-SNAPSHOT</version> <name>demo</name> <packaging>war</packaging> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>17</java.version> <maven.compiler.source>17</maven.compiler.source> <maven.compiler.target>17</maven.compiler.target> <junit.version>5.9.2</junit.version> <spring.boot.version>3.1.5</spring.boot.version> <mybatis.version>3.0.3</mybatis.version> </properties> <!-- Maven 示例 --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>3.1.5</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependencies> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.8.3</version> </dependency> <dependency> <groupId>com.example</groupId> <artifactId>springMybatis</artifactId> <version>1.0-SNAPSHOT</version> </dependency> </dependencies> <build> <plugins> <!-- Maven WAR Plugin --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>3.3.2</version> </plugin> </plugins> </build> </project> 请给出子pom应该如何写 放在什么位置
最新发布
07-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

叶孤心丶

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值