<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/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.sankuai.qcs</groupId> <artifactId>qcs-regulation-parent</artifactId> <version>1.2.7.1-SNAPSHOT</version> <packaging>pom</packaging> <parent> <groupId>com.meituan.mdp</groupId> <artifactId>mdp-parent</artifactId> <version>1.2.6</version> </parent> <scm> <url>http://git.sankuai.com/scm/qcs/qcs-regulation-core</url> <developerConnection>scm:git:http://git.sankuai.com/scm/qcs/qcs-regulation-core.git</developerConnection> <connection>scm:git:http://git.sankuai.com/scm/qcs/qcs-regulation-core.git</connection> <tag>v1.2.0</tag> </scm> <distributionManagement> <repository> <id>meituan-nexus-releases</id> <name>Repository for releases artifacts</name> <url>http://pixel.sankuai.com/repository/releases</url> </repository> <snapshotRepository> <id>meituan-nexus-snapshots</id> <name>Repository for snapshots artifacts</name> <url>http://pixel.sankuai.com/repository/snapshots</url> </snapshotRepository> </distributionManagement> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <java.version>1.8</java.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <qcs-regulation-core.version>1.2.8.1-SNAPSHOT</qcs-regulation-core.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> <version>2.6.0</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.58</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>com.meituan.mdp.boot</groupId> <artifactId>mdp-boot-starter-mafka</artifactId> </dependency> <dependency> <groupId>com.meituan.mdp.boot</groupId> <artifactId>mdp-boot-starter-log</artifactId> </dependency> <dependency> <groupId>com.meituan.mdp.boot</groupId> <artifactId>mdp-boot-starter-config</artifactId> </dependency> <dependency> <groupId>com.meituan.mdp.boot</groupId> <artifactId>mdp-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.meituan.mdp.boot</groupId> <artifactId>mdp-boot-starter-squirrel</artifactId> </dependency> <dependency> <groupId>com.meituan.mdp.component</groupId> <artifactId>swagger-analysis-core</artifactId> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-ext</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.sankuai.qcs</groupId> <artifactId>qcs-regulation-core</artifactId> <version>${qcs-regulation-core.version}</version> <exclusions> <exclusion> <groupId>com.meituan.mafka</groupId> <artifactId>mafka-client_2.9</artifactId> </exclusion> <exclusion> <groupId>com.sankuai.meituan</groupId> <artifactId>mtconfig-client</artifactId> </exclusion> <exclusion> <groupId>com.meituan.log</groupId> <artifactId>scribe-log4j2</artifactId> </exclusion> <exclusion> <groupId>com.meituan.inf</groupId> <artifactId>xmd-log4j2</artifactId> </exclusion> <exclusion> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> </exclusion> <exclusion> <groupId>com.jcraft</groupId> <artifactId>jsch</artifactId> </exclusion> <exclusion> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <encoding>${project.build.sourceEncoding}</encoding> <source>${java.version}</source> <target>${java.version}</target> <debug>true</debug> </configuration> </plugin> <!--mvn release 版本号--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>2.5.3</version> <configuration> <tagNameFormat>v@{project.version}</tagNameFormat> <autoVersionSubmodules>true</autoVersionSubmodules> </configuration> </plugin> </plugins> </build> </project>
如上代码:
首先 系统要先从
(1) <dependencies> 强制引用
(2)</dependencyManagement> 强制引用
(3)然后是 <parent> 里面 强制引用找;
(4)如果实在是没有了,就从 dependencies 的间接引用 找;
比如在 dependency 里面有:
<dependency> <groupId>com.sankuai.qcs</groupId> <artifactId>qcs-regulation-core</artifactId> <version>${qcs-regulation-core.version}</version> </dependency>
而:
core里面有:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
那么 fastjson 属于间接引用;会在第四部执行;
如果我想要制定fastjson的版本直接在dependencyManagement里面指定:
<dependencyManagement> <dependencies> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-pool2</artifactId> <version>2.6.0</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.58</version> </dependency> </dependencies> </dependencyManagement>
这样,dependency里面所有的 有引用 fastjson 的地方全部变成了:1.2.58