Maven继承和依赖

UserMath依赖Math,UserMath(mysql)依赖MathParent

MathParent 父类 pom junit 往下继承,mysql 不会往下继承

<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>net.xinqushi</groupId>
  <artifactId>MathParent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>
  <name>MathParent</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <junit-version>4.12</junit-version>
    <mysql-version>6.0.6</mysql-version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit-version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <dependencyManagement>
  	  <dependencies>
  	  	<dependency>
    		<groupId>mysql</groupId>
   			<artifactId>mysql-connector-java</artifactId>
  			<version>${mysql-version}</version>
  	  	</dependency>
  	  </dependencies>
  </dependencyManagement>
</project>

Math类pom

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <artifactId>Math</artifactId>
  <packaging>jar</packaging>
  <parent>
  <groupId>net.xinqushi</groupId>
  <artifactId>MathParent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <relativePath>..\MathParent</relativePath>
  </parent>
  <properties>
    <argLine>-Dfile.encoding=UTF-8</argLine>
  </properties>

  <dependencies>
  	
  </dependencies>
  <build>
  </build>
</project>

UserMath类pom  

<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>
  <artifactId>UserMath</artifactId>
  <packaging>jar</packaging>
  <parent>
  <groupId>net.xinqushi</groupId>
  <artifactId>MathParent</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <relativePath>..\MathParent</relativePath>
  </parent>
  <properties>
    <argLine>-Dfile.encoding=UTF-8</argLine>
  </properties>
  
  <dependencies>
    <dependency>
      <groupId>net.xinqushi</groupId>
      <artifactId>Math</artifactId>
      <version>0.0.1-SNAPSHOT</version>
    </dependency>
     <dependency>
      <groupId>mysql</groupId>
   	  <artifactId>mysql-connector-java</artifactId>
    </dependency>
  </dependencies>
  
<build>
 </build>
</project>

猜你喜欢

转载自blog.csdn.net/tangbin0505/article/details/82804662
今日推荐