pom.xml文件详解

1. 父pom.xml文件


<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>
    <parent>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-parentartifactId>
        <version>2.1.9.RELEASEversion>
        <relativePath/>
    parent>
    <groupId>com.cloud.creagroupId>
    <artifactId>crea-cloudartifactId>
    <version>1.0.0version>
    <packaging>pompackaging>
    <name>Common-Businessname>

    <properties>
        <java.version>1.8java.version>
        <spring.boot.version>2.1.9.RELEASEspring.boot.version>
        <crea-common.version>1.0.1crea-common.version>
        <spring-cloud.version>Greenwich.SR3spring-cloud.version>
        <com-alibaba-cloud.version>2.1.1.RELEASEcom-alibaba-cloud.version>
        <spring-platform-bom.version>Cairo-SR8spring-platform-bom.version>
        <mysql-connector.version>8.0.18mysql-connector.version>
        <spring-boot-admin.version>2.1.6spring-boot-admin.version>
        <mybatis-plus.version>3.2.0mybatis-plus.version>
        <mybatis.version>3.5.7mybatis.version>
        <mybatis-dynamic-datasource.version>3.1.1mybatis-dynamic-datasource.version>
        <dockerfile.maven.version>1.4.13dockerfile.maven.version>
        <docker-maven-plugin.version>0.4.13docker-maven-plugin.version>
        <docker.baseImage>openjdk:8u212-jredocker.baseImage>
        <docker.volumes>/tmpdocker.volumes>
        <docker.image.prefix>crea_clouddocker.image.prefix>
        <docker.host>https://121.40.154.203:2375docker.host>

        <docker.java.security.egd>-Djava.security.egd=file:/dev/./urandomdocker.java.security.egd>
        <docker.java.opts>-Xms128m -Xmx128mdocker.java.opts>
        <fastdfs-client>1.26.5fastdfs-client>
    properties>

    <dependencies>
        <dependency>
            <groupId>p6spygroupId>
            <artifactId>p6spyartifactId>
            <version>${p6spy.version}version>
        dependency>
    dependencies>
	
	
    <dependencyManagement>
    	dependencies>
            <dependency>
                <groupId>com.baomidougroupId>
                <artifactId>mybatis-plus-boot-starterartifactId>
                <version>${mybatis-plus.version}version>
                <exclusions>
                    <exclusion>
                        <groupId>org.mybatisgroupId>
                        <artifactId>mybatisartifactId>
                    exclusion>
                exclusions>
            dependency>
            <dependency>
                <groupId>org.mybatisgroupId>
                <artifactId>mybatisartifactId>
                <version>${mybatis.version}version>
            dependency>
            <dependency>
                <groupId>com.baomidougroupId>
                <artifactId>dynamic-datasource-spring-boot-starterartifactId>
                <version>${mybatis-dynamic-datasource.version}version>
            dependency>
        dependencies>
          
    dependencyManagement>

    <build>
        <resources>
            <resource>
                <directory>src/main/resourcesdirectory>
                <filtering>truefiltering>
                <includes>
                    <include>**/*.propertiesinclude>
                includes>
            resource>
            <resource>
                <directory>src/main/resourcesdirectory>
                <filtering>falsefiltering>
                <excludes>
                    <exclude>**/*.propertiesexclude>
                excludes>
            resource>
        resources>
        <pluginManagement>
            <plugins>
                
                <plugin>
                    <groupId>org.springframework.bootgroupId>
                    <artifactId>spring-boot-maven-pluginartifactId>
                    <version>${spring.boot.version}version>
                    <configuration>
                        <includeSystemScope>trueincludeSystemScope>
                        <finalName>${project.build.finalName}finalName>
                    configuration>
                    <executions>
                        <execution>
                            <goals>
                                <goal>repackagegoal>
                            goals>
                        execution>
                    executions>
                plugin>
                
                <plugin>
                    <groupId>com.spotifygroupId>
                    <artifactId>docker-maven-pluginartifactId>
                    <version>${docker-maven-plugin.version}version>
                    <configuration>
                        
                        <dockerHost>${docker.host}dockerHost>

                        
                        <imageName>${docker.image.prefix}/${project.artifactId}imageName>
                        
                        <imageTags>
                            <imageTag>latestimageTag>
                        imageTags>
                        
                        
                        <dockerDirectory>${pom.basedir}dockerDirectory>
                        <dockerCertPath>E:\桌面文件\目录\活力狮公有云docker证书\client_pem203dockerCertPath>

                        <resources>
                            <resource>
                                <targetPath>/targetPath>
                                <directory>${project.build.directory}directory>
                                <include>${project.build.finalName}.jarinclude>
                            resource>
                        resources>
                    configuration>
                plugin>
            plugins>
        pluginManagement>
        <plugins>
            <plugin>
                
                <inherited>falseinherited>
                <groupId>com.spotifygroupId>
                <artifactId>docker-maven-pluginartifactId>
                <configuration>
                    <skipDockerBuild>trueskipDockerBuild>
                configuration>
            plugin>
            <plugin>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-maven-pluginartifactId>
            plugin>
            <plugin>
                <artifactId>maven-compiler-pluginartifactId>
                <configuration>
                    <source>${java.version}source>
                    <target>${java.version}target>
                    <encoding>UTF-8encoding>
                    <compilerArgs>
                        <arg>-parametersarg>
                    compilerArgs>
                configuration>
            plugin>
        plugins>
    build>

    <distributionManagement>
        <repository>
            <id>ge-releasesid>
            <url>http://192.168.0.82:30102/repository/ge-releases/url>
        repository>
        <snapshotRepository>
            <id>ge-snapshotsid>
            <url>http://192.168.0.82:30102/repository/ge-snapshots/url>
        snapshotRepository>
    distributionManagement>

    <modules>
        <module>crea-commonmodule>
        <module>crea-gatewaymodule>
        <module>crea-monitormodule>
        <module>crea-authmodule>
        <module>crea-jobmodule>
        <module>crea-service-toolmodule>
        <module>crea-servermodule>
    modules>
project>

2. 子pom.xml文件

3. 父类dependencyManagement标签

使用dependencyManagement标签可以让所有在子项目中引用一个依赖而不用显示的列出版本号。

maven会沿着父子层级往上走,直到找到一个拥有dependencyManagement元素的项目,然后他就会使用dependencyManagement标签中指定的版本号。

如果有多个子项目都引用一样的依赖,则可以避免在每个使用的子项目中都声明一个版本号,这样当想升级或者切换到另一个版本时,只需要在顶层父容器中更新,而不需要一个一个子项目修改。

注意:

  • dependencyManagement只是声明依赖,并不是先引入,因此子项目需要显示的声明需要用的依赖,如果不再子项目中声明依赖,是不会从副项目中继承下来的
  • 如果子项目需要一个自己单独的版本,只需要在子项目pom中声明自己想要的version即可

你可能感兴趣的:(maven,学习)