欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Maven的POM常用標(biāo)簽詳解

 更新時(shí)間:2025年09月10日 11:21:58   作者:咖啡Beans  
本文介紹maven中pom常用標(biāo)簽作用和用法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

摘要

本文介紹maven中pom常用標(biāo)簽作用和用法。

核心部分

<!-- 依賴的集合 -->
<dependencies>
    <!-- 具體某個(gè)依賴 -->
    <dependency>
        <!-- 組織或項(xiàng)目的頂級(jí)域名,通常為反向域名 -->
        <groupId>com.alibaba</groupId>
        <!-- 項(xiàng)目名稱,通常與項(xiàng)目模塊名一致 -->
        <artifactId>easyexcel</artifactId>
        <!-- 項(xiàng)目版本號(hào),遵循語義化版本規(guī)范 ${}讀取屬性值 也可寫死4.0.3 -->
        <version>${easyexcel.version}</version>
        <!-- jar包的類型,默認(rèn)jar -->
        <type>jar</type>
        <!-- 默認(rèn)作用域。表示該依賴在項(xiàng)目的編譯、測(cè)試、運(yùn)行等所有階段都可用,且會(huì)被打包到最終的項(xiàng)目產(chǎn)物中 -->
        <scope>compile</scope>
        <!-- 此依賴是否可選,可選依賴不會(huì)被傳遞到依賴該項(xiàng)目的其他項(xiàng)目中 -->
        <optional>true</optional>
        <!-- 排除依賴的集合 -->
        <exclusions>
            <!-- 具體某個(gè)排除的坐標(biāo)  這里不寫版本號(hào),跟隨依賴版本-->
            <exclusion>
                <groupId>org.apache.poi</groupId>
                <artifactId>poi-ooxml-schemas</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

父模塊pom.xml

<?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>
    <!-- 組織或項(xiàng)目的頂級(jí)域名,通常為反向域名 -->
    <groupId>org.coffeebeans</groupId>
    <!-- 項(xiàng)目名稱,通常與項(xiàng)目模塊名一致 -->
    <artifactId>myproject</artifactId>
    <!-- 項(xiàng)目版本號(hào),遵循語義化版本規(guī)范 -->
    <version>1.0.0</version>
    <!-- 打包方式,父模塊這里是pom -->
    <packaging>pom</packaging>
    <!-- 子模塊列表 -->
    <modules>
        <!-- 具體模塊 -->
        <module>pom-use</module>
    </modules>

    <!-- 自定義屬性 可定義全局通用屬性和管理版本-->
    <properties>
        <!-- 編譯jdk版本 -->
        <maven.compiler.source>8</maven.compiler.source>
        <!-- 運(yùn)行jdk版本 -->
        <maven.compiler.target>8</maven.compiler.target>
        <!-- 編碼 -->
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <!-- 統(tǒng)一管理依賴版本 -->
        <spring-boot.version>2.7.18</spring-boot.version>
    </properties>

    <!-- 統(tǒng)一管理依賴 -->
    <dependencyManagement>
        <!-- 統(tǒng)一管理依賴版本 -->
        <dependencies>
            <!-- 具體依賴 -->
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <!-- 指定依賴是一個(gè)pom文件,而不是一個(gè)jar文件。這通常用于依賴管理(例如,導(dǎo)入其他pom文件中的依賴管理部分)-->
                <type>pom</type>
                <!-- 此依賴僅用于<dependencyManagement>中導(dǎo)入其他 POM 文件中的依賴管理,但本身不會(huì)被傳遞 -->
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    <!-- 項(xiàng)目依賴的存儲(chǔ)庫地址 -->
    <repositories>
        <repository>
            <id>public</id>
            <name>aliyun nexus</name>
            <url>https://maven.aliyun.com/repository/public</url>
            <!-- 默認(rèn)true,啟用從該存儲(chǔ)庫獲取正式版本的依賴 -->
            <releases>
                <enabled>true</enabled>
            </releases>
        </repository>
    </repositories>

</project>

子模塊pom.xml

<?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>
    <!-- 繼承的父pom及識(shí)別坐標(biāo) -->
    <parent>
        <groupId>org.coffeebeans</groupId>
        <artifactId>myproject</artifactId>
        <version>1.0.0</version>
    </parent>

    <!-- 項(xiàng)目名 -->
    <name>pom-use</name>
    <!-- 項(xiàng)目描述 -->
    <description>演示項(xiàng)目依賴標(biāo)簽的使用</description>
    <!-- 打包方式,默認(rèn)jar,可以是pom,jar,war -->
    <packaging>jar</packaging>
    <!-- 當(dāng)前pom的id,通常與項(xiàng)目模塊名一致 -->
    <artifactId>pom-use</artifactId>

    <!-- 自定義屬性 可定義全局通用屬性和管理版本-->
    <properties>
        <!-- 編譯jdk版本 -->
        <maven.compiler.source>8</maven.compiler.source>
        <!-- 運(yùn)行jdk版本 -->
        <maven.compiler.target>8</maven.compiler.target>
        <!-- 編碼 -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <!-- 統(tǒng)一管理依賴版本 -->
        <easyexcel.version>4.0.3</easyexcel.version>
    </properties>

    <!-- 依賴的集合 -->
    <dependencies>
        <!-- 具體某個(gè)依賴 -->
        <dependency>
            <!-- 組織或項(xiàng)目的頂級(jí)域名,通常為反向域名 -->
            <groupId>com.alibaba</groupId>
            <!-- 項(xiàng)目名稱,通常與項(xiàng)目模塊名一致 -->
            <artifactId>easyexcel</artifactId>
            <!-- 項(xiàng)目版本號(hào),遵循語義化版本規(guī)范 ${}讀取屬性值 也可寫死4.0.3 -->
            <version>${easyexcel.version}</version>
            <!-- jar包的類型,默認(rèn)jar -->
            <type>jar</type>
            <!-- 默認(rèn)作用域。表示該依賴在項(xiàng)目的編譯、測(cè)試、運(yùn)行等所有階段都可用,且會(huì)被打包到最終的項(xiàng)目產(chǎn)物中 -->
            <scope>compile</scope>
            <!-- 此依賴是否可選,可選依賴不會(huì)被傳遞到依賴該項(xiàng)目的其他項(xiàng)目中 -->
            <optional>true</optional>
            <!-- 排除依賴的集合 -->
            <exclusions>
                <!-- 具體某個(gè)排除的坐標(biāo)  這里不寫版本號(hào),跟隨依賴版本-->
                <exclusion>
                    <groupId>org.apache.poi</groupId>
                    <artifactId>poi-ooxml-schemas</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.3</version>
            <!-- 此依賴僅在編譯和測(cè)試時(shí)需要,運(yùn)行時(shí)由容器提供,不會(huì)被打包到最終的項(xiàng)目產(chǎn)物中 -->
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.29</version>
            <!-- 此依賴僅在運(yùn)行和測(cè)試時(shí)需要,編譯時(shí)不需要,會(huì)打包到最終的項(xiàng)目產(chǎn)物中 -->
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <!-- 僅在測(cè)試編譯和測(cè)試運(yùn)行時(shí)使用,不會(huì)被打包到最終的項(xiàng)目產(chǎn)物中,也不會(huì)被傳遞到依賴該項(xiàng)目的其他項(xiàng)目中。-->
            <scope>test</scope>
        </dependency>
    </dependencies>

    <!-- 構(gòu)建的集合 -->
    <build>
        <!-- 打包后的文件名 -->
        <finalName>pom-use</finalName>
        <!-- 插件的集合 -->
        <plugins>
            <!-- 打包插件 -->
            <plugin>
                <!-- 組織或項(xiàng)目的頂級(jí)域名,通常為反向域名 -->
                <groupId>org.springframework.boot</groupId>
                <!-- 項(xiàng)目名稱,通常與項(xiàng)目模塊名一致 -->
                <artifactId>spring-boot-maven-plugin</artifactId>
                <!-- 項(xiàng)目版本號(hào),遵循語義化版本規(guī)范 ${}讀取屬性值 也可寫死2.7.11 -->
                <version>2.7.11</version>
                <!-- 插件的配置 -->
                <configuration>
                    <!-- 啟用fork,表示測(cè)試代碼將在一個(gè)新的 JVM 進(jìn)程中運(yùn)行,而不是在 Maven 運(yùn)行的當(dāng)前 JVM 中運(yùn)行 -->
                    <fork>true</fork>
                    <!-- 打包后的輸出目錄 -->
                    <outputDirectory>../pom-use</outputDirectory>
                </configuration>
                <!-- 插件的執(zhí)行 -->
                <executions>
                    <!-- 具體執(zhí)行項(xiàng) -->
                    <execution>
                        <!-- 目標(biāo) -->
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    
    <!-- 環(huán)境配置 -->
    <profiles>
        <!-- 開發(fā)環(huán)境 -->
        <profile>
            <id>dev</id>
            <properties>
                <profiles.active>dev</profiles.active>
                <!-- 其他配置,如端口-->
                <port>1000</port>
            </properties>
            <!-- 默認(rèn)激活 -->
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
        </profile>
        <!-- 生產(chǎn)環(huán)境 -->
        <profile>
            <id>prod</id>
            <properties>
                <profiles.active>prod</profiles.active>
                <port>2000</port>
            </properties>
        </profile>
        <!-- 測(cè)試環(huán)境 -->
        <profile>
            <id>test</id>
            <properties>
                <profiles.active>test</profiles.active>
                <port>3000</port>
            </properties>
        </profile>
    </profiles>

</project>

總結(jié)

以上我們了解了maven中pom里常用標(biāo)簽作用和用法。更多相關(guān)Maven POM常用標(biāo)簽內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論