点击查看代码
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- 继承父类的坐标 父项目 A-->
<parent>
<groupId>com.bjsxt</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.bisxt</groupId>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- 通过dependencyManagement标签添加父类-->
<dependencyManagement>
<dependencies>
<!-- 父项目B-->
<dependency>
<groupId>com.bisxt</groupId>
<artifactId>parent_b</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
</dependencies>
</project>
2.多继承二
点击查看代码
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- 继承父类的坐标 父项目 A-->
<!-- <parent>-->
<!-- <groupId>com.bjsxt</groupId>-->
<!-- <artifactId>parent</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- </parent>-->
<groupId>com.bisxt</groupId>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
<!-- 通过dependencyManagement标签添加父类-->
<dependencyManagement>
<dependencies>
<!-- 父项目B-->
<dependency>
<groupId>com.bisxt</groupId>
<artifactId>parent_b</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.bjsxt</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
</dependencies>
</project>