Maven 之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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>haitun-report</groupId>
    <artifactId>haitun-report</artifactId>
    <version>1.0.0</version>
    <name>haitun-report</name>
    <!--打包方式
        1.父工程                pom
        2.web需要额外容器部署    war
        3.普通工程               jar
    -->
    <packaging>pom</packaging>

    <!--所包含的子模块-->
    <modules>
        <module>haitun-report-server</module>
        <module>haitun-report-service</module>
        <module>haitun-report-worker</module>
    </modules>

    <!--依赖的父工程-->
    <parent>
        <groupId>com.javxuan.boot</groupId>
        <artifactId>my-boot</artifactId>
        <version>1.3.5.RELEASE</version>
        <!--以当前pom文件的位置往上找到父级pom文件-->
        <relativePath>../pom.xml</relativePath>
    </parent>

    <!--版本管理-->
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.8</java.version>
        <spring.version>4.2.7.RELEASE</spring.version>
    </properties>

    <!--依赖管理 专门管理那些不能通过继承传递的依赖 如junit 
        1.在这里管理依赖的version等, 
        2.在子模块中同样要引入坐标,但是不用声明版本好,以此来统一junit的版本
         <dependency>
               <groupId>junit</groupId>
               <artifactId>junit</artifactId>
         </dependency>  
    -->
    <dependencyManagement>
        <dependencies>
           <dependency>
               <groupId>junit</groupId>
               <artifactId>junit</artifactId>
               <version>4.12</version>
               <scope>test</scope>
           </dependency>
       </dependencies>
    </dependencyManagement>

    <!--添加依赖-->
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>

    <!--profile 设置不同的环境-->
    <profiles>
       <profile>
           <id>dev</id>
           <activation>
               <activeByDefault>true</activeByDefault>
           </activation>
           <properties>
               <evn>dev</evn>
           </properties>
           <build>
               <filters>
                   <filter>src/main/resources/application-dev.yml</filter>
               </filters>
           </build>
       </profile>

       <profile>
           <id>test</id>
           <properties>
               <evn>test</evn>
           </properties>
           <build>
               <filters>
                   <filter>src/main/resources/application-test.yml</filter>
               </filters>
           </build>
       </profile>

       <profile>
           <id>beta</id>
           <properties>
               <evn>beta</evn>
           </properties>
           <build>
               <filters>
                   <filter>src/main/resources/application-beta.yml</filter>
               </filters>
           </build>
       </profile>

       <profile>
           <id>prod</id>
           <properties>
               <evn>prod</evn>
           </properties>
           <build>
               <filters>
                   <filter>src/main/resources/application-prod.yml</filter>
               </filters>
           </build>
       </profile>
  </profiles>

    <!--编译-->
    <build>
        <!--资源加载位置-->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <!--插件-->
       <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                      <goals>
                        <goal>repackage</goal>
                      </goals>
                    </execution>
                 </executions>
            </plugin>

        </plugins>
        <defaultGoal>compile</defaultGoal>
    </build>


</project>

猜你喜欢

转载自blog.csdn.net/u014297148/article/details/80445214