1. 程式人生 > 其它 >maven-pom.xml 配置詳解

maven-pom.xml 配置詳解

pom基本配置:
pom.xml 是 Maven 專案的核心配置檔案,位於每個工程的根目錄,基本配置如下:

:檔案的根節點 .
: pom.xml 使用的物件模型版本
:專案名稱,一般寫專案的域名
:模組名稱,子專案名或模組名稱
:產品的版本號 .
:打包型別,一般有 jar、war、pom 等
:專案的顯示名,常用於 Maven 生成的文件。
:專案描述,常用於 Maven 生成的文件
:專案依賴構件配置,配置專案依賴構件的座標
:專案構建配置,配置編譯、執行外掛等。

<?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>com.study</groupId>
    <artifactId>maven_parent</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

<!--聚合工程-->
    <modules>
        <module>maven_dao</module>
        <module>maven_pojo</module>
        <module>maven_service</module>
        <module>maven_web</module>
    </modules>

    <properties>
        <mybatis.version>3.4.5</mybatis.version>
    </properties>
<!--鎖定jar版本-->
    <dependencyManagement>
        <dependencies>
            <!-- Mybatis -->
            <dependency>
                <groupId>org.mybatis</groupId>
                <artifactId>mybatis</artifactId>
                <version>${mybatis.version}</version>
            </dependency>
     <dependencies>
 <dependencyManagement>

    <!--編譯外掛-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>


</project>