美文网首页
maven父子工程里面的pom依赖处理

maven父子工程里面的pom依赖处理

作者: 刘书生 | 来源:发表于2019-03-28 15:24 被阅读0次

    父工程pom依赖结构图

    <?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">
    
        <!--项目说明:这里作为聚合工程的父工程-->
        <groupId>com.wgd</groupId>
        <artifactId>parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    
        <!--基本信息-->
        <description>Demo project for Spring Boot</description>
        <modelVersion>4.0.0</modelVersion>
        <name>parent</name>
        <packaging>pom</packaging>
    
        <!--模块说明:这里声明多个模块-->
        <modules>
    
        </modules>
    
        <!--版本号-->
        <properties>
            <Gson.version>2.8.5</Gson.version>
            <jackson.version>2.9.8</jackson.version>
        </properties>
    
        <!--将共有的依赖放在这里-->
        <dependencies>
           <!--GSON-->
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>${Gson.version}</version>
            </dependency>
        </dependencies>
    
        <!--版本说明:这里统一管理依赖的版本号-->
        <dependencyManagement>
               <!-- 统一管理Spring依赖 -->
                <dependency>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-dependencies</artifactId>
                    <version>${spring.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
    
               <dependency>
                    <groupId>com.fasterxml.jackson.core</groupId>
                    <artifactId>jackson-databind</artifactId>
                    <version>${jackson.version}</version>
                </dependency>
        </dependencyManagement>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${compiler.version}</version>
                    <configuration>
                        <source>${source.version}</source>
                        <target>${target.version}</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </project>
    
    

    子工程pom图

    <?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">
        <parent>
            <artifactId>parent</artifactId>
            <groupId>com.wgd</groupId>
            <version>0.0.1-SNAPSHOT</version>
        </parent>
        <modelVersion>4.0.0</modelVersion>
    
        <artifactId>common</artifactId>
        <groupId>com.wgd</groupId>
        <version>0.0.1-SNAPSHOT</version>
    
        <dependencies>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
            </dependency>
        </dependencies>
    </project>
    

    相关文章

      网友评论

          本文标题:maven父子工程里面的pom依赖处理

          本文链接:https://www.haomeiwen.com/subject/pfnqbqtx.html