设为首页 加入收藏

TOP

Maven中dependency和plugins的继承与约束(一)
2019-02-28 00:08:35 】 浏览:296
Tags:Maven dependency plugins 继承 约束

Maven的父子项目


父子项目核心点是在于通过将一个大项目拆分为若干子模块,每个模块以子项目的形式存在,不同的子项目共享父项目的设置与约束。所以,父项目承担的角色是建立各个子项目的约束和一致的基础。


父项目配置
<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.parent.project</groupId>
    <artifactId>project-artifiact</artifactId>
    <version>0.0.1.7-SNAPSHOT</version>
    <packaging>pom</packaging>
 
  <!-- dependency in inheritance -->
  <depdencies>
    <dependency>
          <groupId>org.apache.commons</groupId>
          <artifactId>commons-lang3</artifactId>
          <version>3.8.1</version>
      </dependency>
  </dependencies>


  <!-- depdency constraints -->
  </dependencies>
  <dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactid>junit</artifactId>
      <version>4.8.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactid>log4j</artifactId>
      <version>1.2.16</version>
    </dependency>
  </dependencies>
</dependencyManagement>


<!-- plugin constraints -->
<pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-source-plugin</artifactId>
            <version>2.1</version>
            <configuration>
                <attach>true</attach>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</pluginManagement>


<modules>
  <module>A</modul

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Spring MVC之redirect、forward和.. 下一篇C++与Python混合编程:Boost.Pyth..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目