美文网首页
Maven多模块的父级pom写法

Maven多模块的父级pom写法

作者: 苗義 | 来源:发表于2019-08-03 12:04 被阅读0次

Maven多模块的父级pom写法注意

最近打算重新搭建微服务项目的,遇到pom的写法问题,记录下来。

[TOC]

写法一、parent+dependencyManagement标签

在父pom中通过<parent>和<dependencyManagement>标签来管理jar包版本:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.6.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
...
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    <spring-boot.version>2.1.6.RELEASE</spring-boot.version>
    <spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
</properties>
...
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

很多的公司,视频中都是这么做的。

写法二、dependencyManagement标签

父级pom中通过dependencyManagement标签来管理

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring-boot-dependencies.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

相关文章

  • Maven多模块的父级pom写法

    Maven多模块的父级pom写法注意 最近打算重新搭建微服务项目的,遇到pom的写法问题,记录下来。 [TOC] ...

  • 父文件pom.xml文件

    maven实现多模块化中父项目pom.xml文件

  • Rainbond Java Maven 多模块源码构建

    Maven 多模块项目构建识别策略 Maven 多模块项目是根据 pom.xml 文件(下面简称 pom)来划分的...

  • maven profile

    profile 能让maven项目在不同的环境下加载不同的配置,在pom文件中加入(如果是多模块项目,加在父POM...

  • Idea-Maven多模块开发

    公司开发:多项目开发(含多模块),基于模块的开发 方式一:新建立Maven站点pom项目: 有一个父工程,有多个子...

  • SpringBoot整合dubbo

    首先创建一个多模块Maven项目,再创建一个生产者子项目和一个消费者子项目。父模块Maven POM文件如下: 生...

  • Missing artifact com.github.page

    创建maven项目pom.xml出现错误(依赖Missing) Maven的依赖问题 在聚合模块时候,发现在父工程...

  • SpringBoot创建多Module项目以及问题排查

    前言 Maven多模块项目通常由一个父模块和若干个子模块构成,每个模块都对应着一个pom.xml。它们之间通过继承...

  • maven

    maven多模块项目eclipse中创建maven pom工程http://jingyan.baidu.com/a...

  • Maven多模块项目Eclipse转Idea

    Maven多模块项目调整 所有子项目删除其它文件只留下src和pom.xml文件,父项目只留下子项目文件夹和父po...

网友评论

      本文标题:Maven多模块的父级pom写法

      本文链接:https://www.haomeiwen.com/subject/ickjdctx.html