First, write a maven parent
<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.lala</groupid><artifactid>my-parent </artifactid><version>0.0.1</version><packaging>pom</packaging><properties ><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties>< Dependencies><dependency><groupid>junit</groupid><artifactid>junit</artifactid ><version>4.11</version><scope>test</scope></dependency><dependency> <groupId>redis.clients</groupId><artifactId>jedis</artifactId><version>2.4.0< /version><scope>provided</scope></dependency></dependencies>< Dependencymanagement><dependencies><dependency><groupid>javax.mail</groupid><artifactid>javax.mail-api</artifactid>< Version>1.5.3</version><scope>provided</scope></dependency></dependencies> </dependencymanagement><build><plugins><plugin><groupid>org.apache.maven.plugins </groupId><artifactId>maven-compiler-plugin</artifactId><version>3.3</version> <configuration><source>1.8</source><target>1.8</target><verbose>true</ Verbose></configuration></plugin></plugins></build></project>
The dependencies inside is: 2.4.0 's Jedis
The dependencymanagement inside is: 1.5.3 's Java.mail
The sub-module is written like this.
<parent><groupid>com.lala</groupid><artifactid>my-parent</artifactid><version >0.0.1</version></parent>
will have the following reaction:
1: The submodule automatically introduces the parent module's dependencies dependency without automatically introducing the dependencymanagement dependency
2:dependencymanagement only declares dependencies, does not implement the introduction, so the subproject needs to explicitly declare the required dependencies, and do not need to specify version, scope, the system will automatically use the parent module version, scope
MAVEN Technical Exchange Buckle Group 379165311, the group will occasionally share some Maven articles and tutorials, you are welcome to join
Dependencies and Dependencymanagement differences in MAVEN Parent