SpringBoot Maven pom基本介紹2


<?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>org.imi</groupId>
<!--專案名-->
<artifactId>myDemo</artifactId>
<!--版本 SNAPSHOT為不穩定版本-->
<version>1.0.0</version>
<packaging>war</packaging>
<name>myDemo</name>
<description>這是一個demo用的專案</description>

<!--變數設置-->
<properties>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<!--繼承springframework-->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.7</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<!--多環境建置-->
<profiles>
<!--開發環境-->
<profile>
<id>dev</id>
<properties>
<activatedProperties>dev</activatedProperties>
</properties>
<activation>
<!--默認環境-->
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<!--正式環境-->
<profile>
<id>prod</id>
<properties>
<activatedProperties>prod</activatedProperties>
</properties>
</profile>
</profiles>

<!--設定引用函式庫-->
<dependencies>
<!--spring-boot Web服务-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!--spring-boot thymeleaf模版引擎-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<!--spring-boot security安全守護-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>

<!-- &lt;!&ndash;spring-boot jpa 資料庫&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>mysql</groupId>-->
<!-- <artifactId>mysql-connector-java</artifactId>-->
<!-- <scope>runtime</scope>-->
<!-- </dependency>-->

<!-- &lt;!&ndash;spring-boot test單元測試&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-test</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>junit</groupId>-->
<!-- <artifactId>junit</artifactId>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->


<!-- &lt;!&ndash;logback&ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>ch.qos.logback</groupId>-->
<!-- <artifactId>logback-classic</artifactId>-->
<!-- <version>1.2.3</version>-->
<!-- </dependency>-->
</dependencies>

<!--建置專案所需要資訊-->
<build>
<finalName>${project.artifactId}</finalName>
<!--專案使用的程式列表-->
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.6.7</version>
</plugin>
</plugins>

<resources>
<!-- <resource>-->
<!-- <directory>src/main/java</directory>-->
<!-- <includes>-->
<!-- <include>**/*.xml</include>-->
<!-- </includes>-->
<!-- <filtering>false</filtering>-->
<!-- </resource>-->
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>ajax/</include>
<include>static/</include>
<!-- <include>**/*.xml</include>-->
</includes>
</resource>
<!--多環境配置-->
<resource>
<directory>src/main/resources</directory>
<!-- < filtering >true</ filtering >其含义是扫描src/main/resources/下的所有propertiesxml文件将其中的${}引用在打包时换成直接引用。-->
<filtering>true</filtering>
<includes>
<!-- 项目打包完成的包中只包含当前环境文件 -->
<include>application.properties</include>
<include>application-${activatedProperties}.properties</include>
</includes>
<!-- <excludes>-->
<!-- <exclude>static/font/**</exclude>-->
<!-- </excludes>-->
</resource>
</resources>
</build>
</project>