Skip to content

Instantly share code, notes, and snippets.

@albert-hg
Last active July 28, 2020 07:32
Show Gist options
  • Save albert-hg/81fce140535e61a6d5351f809e92c417 to your computer and use it in GitHub Desktop.
Save albert-hg/81fce140535e61a6d5351f809e92c417 to your computer and use it in GitHub Desktop.
the basic structure for 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- 專案的名稱、描述、版本等專案基本資訊 -->
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<name></name>
<description></description>
<!-- 這裡可以設定一些在pom.xml內的變數 -->
<properties>
<!-- 例如這裡設定一個變數名稱為 "java.version" 的變數,其值為 "1.8" -->
<java.version>1.8</java.version>
</properties>
<!-- 這裡管理在這個專案中所使用的套件 -->
<dependencies>
<!-- 例如這裡使用了 "junit" 套件,版本為 "4.11" -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- 這裡可以設定當使用mvn執行建構時所使用的plugin -->
<build>
<plugins>
<!-- 例如當執行 "mvn clean" 時,則會執行這個plugin -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</build>
<!-- 這裡可以設定當使用mvn執行建構時可透過 "mvn -P" 執行不同的建構程序(流程) -->
<profiles>
<profile>
<!-- 例如當執行 "mvn -Pprod" 時,則會使用這個profile的建構內容 -->
<id>prod</id>
<!-- 可以在每個profile中加上特定的dependency -->
<dependencies/>
<!-- 也可以在每個profile中定義不同的建構流程 -->
<build/>
</profile>
</profiles>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment