您好,登錄后才能下訂單哦!
官網: 傳送門
Maven 項目結構
$ MavenProject
|-- pom.xml
|-- src
| |-- main
| | `-- java
| | `-- resources
| `-- test
| | `-- java
| | `-- resources
`-- README.md
<?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>
<packaging>pom</packaging>
<modules>
<module>mscx-ad-discovery</module>
<module>mscx-ad-zuul</module>
<module>mscx-ad-gateway</module>
<module>mscx-ad-discovery-nacos</module>
<module>mscx-ad-common</module>
<module>mscx-ad-db</module>
<module>mscx-ad-sponsor</module>
<module>mscx-ad-search</module>
<module>mscx-ad-feign-sdk</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.sxzhongf</groupId>
<artifactId>mscx-ad</artifactId>
<version>1.0-SNAPSHOT</version>
<name>分布式廣告系統</name>
<description>基于Spring Cloud Alibaba 實現的分布式廣告系統</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<!--定義遠程maven倉庫-->
<repositories>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>alibaba</id>
<name>ali Milestones</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Maven思想 是 約定大于配置,默認依賴中,scope 是compile.
compile(會被打包到當前project)
表示被依賴的package參與當前project的編譯,包含后續的測試,運行周期都會參與,是一個強依賴。
test
表示被依賴的jar 僅參與測試相關的處理,包裹測試代碼的編譯,執行。(如junit)
runtime
表示被依賴的jar不需要參與項目的編譯,但是后期的測試和運行周期需要參與。
provided
打包的時候不需要包含進去,其他的Container會提供該依賴支持,理論上該依賴可以參與編譯、測試運行等周期 ,相當于compile,但是在打包階段做了exclude命令。
system
從參與環境來看,和provided相同,但是被依賴項不會從maven倉庫獲取,而是從本地文件系統獲取,一定需要配合
systemPath
屬性使用
import
This scope is only supported on a dependency of type
pom
in the<dependencyManagement>
section.
官方解釋:傳送門
Dependency mediation (最近依賴原則)
"nearest definition" means that the version used will be the closest one to your project in the tree of dependencies. For example, if dependencies for A, B, and C are defined as A -> B -> C -> D 2.0 and A -> E -> D 1.0, then D 1.0 will be used when building A because the path from A to D through E is shorter. You could explicitly add a dependency to D 2.0 in A to force the use of D 2.0.
根據依賴深度,選擇依賴路徑最近的package version, 如果依賴深度相同,那么選擇前一個。Note that if two dependency versions are at the same depth in the dependency tree, the first declaration wins.
Dependency management
依賴管理(項目作者可直接指定依賴版本)
Dependency scope 如上一節所述
Excluded dependencies 排除依賴包中依賴項
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。