亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Maven下載依賴的順序及配置文件小結(jié)

 更新時間:2023年07月20日 16:23:48   作者:羅羅的1024  
本文主要介紹了Maven下載依賴的順序及配置文件小結(jié),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

在 Maven 中,當下載依賴項時,存在多個倉庫時會按照以下優(yōu)先級順序進行搜索:

  • 本地倉庫:Maven 會首先在本地的 Maven 倉庫中查找依賴項。
  • 私有倉庫(私服):如果在本地倉庫中未找到依賴項,Maven 會按照項目的 pom.xml 文件中配置的 元素指定的順序依次搜索私有倉庫。私有倉庫是你在項目中添加的自定義倉庫,通常是用于存放項目內(nèi)部開發(fā)的依賴項或者第三方庫,它可以是一個本地服務(wù)器或者其他網(wǎng)絡(luò)位置。
  • 中央倉庫(Maven Central Repository):Maven 中央倉庫是 Maven 官方維護的集中存儲庫,包含了大量常用的開源 Java 項目的構(gòu)件和元數(shù)據(jù)。如果項目的 pom.xml 文件沒有指定其他遠程倉庫,并且本地倉庫中也沒有所需的依賴項,Maven 會自動搜索中央倉庫來下載依賴項。
  • 其他遠程倉庫:如果在項目的 pom.xml 文件中配置了其他遠程倉庫地址,并且中央倉庫、私有倉庫和本地倉庫都沒有所需的依賴項,Maven 會按照 中指定的順序依次搜索這些自定義遠程倉庫。

綜上所述,Maven 下載依賴項的優(yōu)先級順序為:本地倉庫 > 遠程倉庫(包括中央倉庫) > 自定義遠程倉庫。Maven 會按照這個順序查找依賴項,直到找到所需的依賴或者搜索完所有配置的倉庫。如果依賴項在某個倉庫中找到了,Maven 會將其下載到本地倉庫,并在后續(xù)構(gòu)建過程中直接使用本地倉庫中的依賴,以加快構(gòu)建速度和確保依賴項的一致性。

Maven的配置文件說明

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. ?See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. ?The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. ?You may obtain a copy of the License at
? ? http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. ?See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
?| This is the configuration file for Maven. It can be specified at two levels:
?|
?| ?1. User Level. This settings.xml file provides configuration for a single user,?
?| ? ? ? ? ? ? ? ? and is normally provided in ${user.home}/.m2/settings.xml.
?|
?| ? ? ? ? ? ? ? ? NOTE: This location can be overridden with the CLI option:
?|
?| ? ? ? ? ? ? ? ? -s /path/to/user/settings.xml
?|
?| ?2. Global Level. This settings.xml file provides configuration for all Maven
?| ? ? ? ? ? ? ? ? users on a machine (assuming they're all using the same Maven
?| ? ? ? ? ? ? ? ? installation). It's normally provided in?
?| ? ? ? ? ? ? ? ? ${maven.home}/conf/settings.xml.
?|
?| ? ? ? ? ? ? ? ? NOTE: This location can be overridden with the CLI option:
?|
?| ? ? ? ? ? ? ? ? -gs /path/to/global/settings.xml
?|
?| The sections in this sample file are intended to give you a running start at
?| getting the most out of your Maven installation. Where appropriate, the default
?| values (values used when the setting is not specified) are provided.
?|
?|-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"?
? ? ? ? ? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?
? ? ? ? ? xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
? <!-- localRepository
? ?| The path to the local repository maven will use to store artifacts.
? ?|
? ?| Default: ${user.home}/.m2/repository
? ?本地倉庫地址
? -->
? <localRepository>D:\Program Files\localMavenRepoistory</localRepository>
? <!-- interactiveMode
? ?| This will determine whether maven prompts you when it needs input. If set to false,
? ?| maven will use a sensible default value, perhaps based on some other setting, for
? ?| the parameter in question.
? ?|
? ?| Default: true
? <interactiveMode>true</interactiveMode>
? -->
? <!-- offline
? ?| Determines whether maven should attempt to connect to the network when executing a build.
? ?| This will have an effect on artifact downloads, artifact deployment, and others.
? ?|
? ?| Default: false
? <offline>false</offline>
? -->
? <!-- pluginGroups
? ?| This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
? ?| when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
? ?| "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
? ?|-->
? <pluginGroups>
? ? <!-- pluginGroup
? ? ?| Specifies a further group identifier to use for plugin lookup.
? ? <pluginGroup>com.your.plugins</pluginGroup>
? ? -->
? </pluginGroups>
? <!-- proxies
? ?| This is a list of proxies which can be used on this machine to connect to the network.
? ?| Unless otherwise specified (by system property or command-line switch), the first proxy
? ?| specification in this list marked as active will be used.
? ?|-->
? <proxies>
? ? <!-- proxy
? ? ?| Specification for one proxy, to be used in connecting to the network.
? ? ?|
? ? <proxy>
? ? ? <id>optional</id>
? ? ? <active>true</active>
? ? ? <protocol>http</protocol>
? ? ? <username>proxyuser</username>
? ? ? <password>proxypass</password>
? ? ? <host>proxy.host.net</host>
? ? ? <port>80</port>
? ? ? <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
? ? </proxy>
? ? -->
? </proxies>
? <!-- servers
? ?| This is a list of authentication profiles, keyed by the server-id used within the system.
? ?| Authentication profiles can be used whenever maven must make a connection to a remote server.
? ?|-->
? <servers>
? ? <!-- server
? ? ?| Specifies the authentication information to use when connecting to a particular server, identified by
? ? ?| a unique name within the system (referred to by the 'id' attribute below).
? ? ?|?
?? ? 在 Maven 中,<server> 元素用于配置認證信息,主要是用于在構(gòu)建過程中訪問需要認證的遠程倉庫或資源
?? ? 當使用 Maven 構(gòu)建項目時,有些遠程倉庫可能需要進行身份驗證(例如私有倉庫),這時候就需要提供訪問該倉庫的用戶名和密碼。
?? ?為了不將用戶名和密碼明文寫在 pom.xml 文件中,可以將認證信息放在 Maven的 settings.xml 文件中的 <servers> 元素中
? ? ?| NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are?
? ? ?| ? ? ? used together.
? ? ?|
? ? <server>
? ? ? <id>deploymentRepo</id>
? ? ? <username>repouser</username>
? ? ? <password>repopwd</password>
? ? </server>
?? ?在上述示例中,配置了一個 <server> 元素,它的 <id> 是 "deploymentRepo",表示該認證信息用于訪問 ID 為 "deploymentRepo" 的遠程倉庫。
?? ?然后,通過 <username> 和 <password> 元素分別提供用戶名和密碼,這些信息將用于在訪問遠程倉庫時進行身份驗證。
當 Maven 需要訪問遠程倉庫或資源時,會檢查 settings.xml 文件中的 <servers> 元素,如果有匹配的 <server> 元素(根據(jù) <id> 屬性匹配),
就會使用該認證信息進行訪問。這樣,就可以安全地在 settings.xml 文件中管理認證信息,而不需要在 pom.xml 文件中明文暴露用戶名和密碼。
? ? -->
? ? <!-- Another sample, using keys to authenticate.
? ? <server>
? ? ? <id>siteServer</id>
? ? ? <privateKey>/path/to/private/key</privateKey>
? ? ? <passphrase>optional; leave empty if not used.</passphrase>
? ? </server>
? ? -->
?? ? <server>
? ? ? ? ? ? <id>releases</id>
? ? ? ? ? ? <username>zs</username>
? ? ? ? ? ? <password>pp</password>
? ? ? ? </server>
? ? ? ? <server>
? ? ? ? ? ? <id>snapshots</id>
? ? ? ? ? ? <username>zs</username>
? ? ? ? ? ? <password>pp</password>
? ? ? ? </server>
? ? ? ? <server>
? ? ? ? ? ? <id>docker.r.io</id>
? ? ? ? ? ? <username>zs</username>
? ? ? ? ? ? <password>pp</password>
? ? ? ? </server>
? </servers>
? <!-- mirrors
? ?| This is a list of mirrors to be used in downloading artifacts from remote repositories.
? ?|?
? ?| It works like this: a POM may declare a repository to use in resolving certain artifacts.
? ?| However, this repository may have problems with heavy traffic at times, so people have mirrored
? ?| it to several places.
? ?|
? ?| That repository definition will have a unique id, so we can create a mirror reference for that
? ?| repository, to be used as an alternate download site. The mirror site will be the preferred?
? ?| server for that repository.
? ?|-->
? <mirrors>
? ? <!-- mirror
? ? ?| Specifies a repository mirror site to use instead of a given repository. The repository that
? ? ?| this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
? ? ?| for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
? ? ?|
? ? <mirror>
? ? ? <id>mirrorId</id>
? ? ? <mirrorOf>repositoryId</mirrorOf>
? ? ? <name>Human Readable Name for this Mirror.</name>
? ? ? <url>http://my.repository.com/repo/path</url>
? ? </mirror>
? ? ?-->
?? ? <!-- mirror
?? ? ? <mirror>
?? ??? ??? ?<id>public</id>
?? ??? ??? ?<name>Nexus Public Mirror</name>
?? ??? ??? ?<url>http://repo.thunisoft.com/maven2/content/groups/public-repo/</url>
?? ??? ??? ?<mirrorOf>central</mirrorOf>
?? ??? ?</mirror>
?? ??? ?<mirror>
?? ??? ??? ?<id>nexus</id>
?? ??? ??? ?<mirrorOf>public-snapshots</mirrorOf>
?? ??? ??? ?<url>http://repo.thunisoft.com/maven2/content/groups/public-snapshots/</url>
?? ??? ?</mirror>
?? ??? ?-->
?? ??? ?<!--鏡像倉庫(Mirror Repository)是一種用于加速依賴項下載的機制。在 Maven 中,當你構(gòu)建項目時,通常需要從遠程倉庫下載各種依賴項(JAR 文件、插件等)。這些遠程倉庫可能分布在全球各地,
?? ??? ?下載速度可能受到網(wǎng)絡(luò)延遲和帶寬限制的影響,導(dǎo)致構(gòu)建過程較慢。
為了解決這個問題,Maven 允許配置一個鏡像倉庫,它是一個位于本地網(wǎng)絡(luò)或高速服務(wù)器上的代理倉庫。當你配置了鏡像倉庫后,Maven 將優(yōu)先嘗試從鏡像倉庫下載依賴項,而不是直接從遠程倉庫下載。
如果鏡像倉庫中已經(jīng)存在所需的依賴項,下載速度將大大加快,因為鏡像倉庫通常位于本地網(wǎng)絡(luò)或高速服務(wù)器上,與開發(fā)者的構(gòu)建環(huán)境更近,網(wǎng)絡(luò)延遲較小。
鏡像倉庫不保存所有的依賴項,它只會緩存從遠程倉庫下載的依賴項。當 Maven 需要下載依賴項時,首先嘗試從鏡像倉庫獲取。
如果在鏡像倉庫中找不到所需的依賴項,Maven 會繼續(xù)從配置的其他遠程倉庫下載。-->
?? ??? ?<mirror>
? ? ? ? ? ? <id>rep</id>
? ? ? ? ? ? <!-- 用于指定該鏡像倉庫代理的目標倉庫。它的作用是告訴 Maven 該鏡像倉庫要替代哪個遠程倉庫的下載請求。?
?? ??? ??? ?當前配置表示這個鏡像倉庫將代理所有遠程倉庫的請求,但會排除掉 ID 分別為 "private1"、"private2" 和 "private3" 的遠程倉庫,這些倉庫的請求將不會由這個鏡像倉庫來處理。
?? ??? ??? ?這樣的配置是有用的,例如,當你有多個私有倉庫,并且想要一個鏡像倉庫來加速下載公共倉庫的依賴項,同時不影響私有倉庫的下載請求。通過排除私有倉庫的 ID,確保私有倉庫的請求不會被這個鏡像倉庫所代理,避免了可能出現(xiàn)的下載問題-->
? ? ? ? ? ? <mirrorOf>*,!private1,!private2,!private3</mirrorOf>
? ? ? ? ? ? <url>http://maven.r.io/</url>
? ? ? ? </mirror>
? </mirrors>
? <!-- profiles
? ?| This is a list of profiles which can be activated in a variety of ways, and which can modify
? ?| the build process. Profiles provided in the settings.xml are intended to provide local machine-
? ?| specific paths and repository locations which allow the build to work in the local environment.
? ?|
? ?| For example, if you have an integration testing plugin - like cactus - that needs to know where
? ?| your Tomcat instance is installed, you can provide a variable here such that the variable is?
? ?| dereferenced during the build process to configure the cactus plugin.
? ?|
? ?| As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
? ?| section of this document (settings.xml) - will be discussed later. Another way essentially
? ?| relies on the detection of a system property, either matching a particular value for the property,
? ?| or merely testing its existence. Profiles can also be activated by JDK version prefix, where a?
? ?| value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
? ?| Finally, the list of active profiles can be specified directly from the command line.
? ?|
? ?| NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
? ?| ? ? ? repositories, plugin repositories, and free-form properties to be used as configuration
? ?| ? ? ? variables for plugins in the POM.
? ?|
? ?Profile是一種用于在不同環(huán)境或需求下為項目定義不同配置選項的機制。
? ?通過使用 Profile,你可以根據(jù)不同的情況激活或禁用特定配置,從而實現(xiàn)項目的定制化構(gòu)建
? ?|-->
? <profiles>
? ?<profile>
? ? ? ? ? ? <id>env1</id>
?? ??? ??? ?<!-- 在 Maven 的 Profile 中,你可以通過 <repositories> 元素來定義特定的倉庫配置。
?? ??? ??? ?這允許你在不同的環(huán)境或需求下為項目指定不同的遠程倉庫,從而實現(xiàn)定制化的依賴管理 -->
? ? ? ? ? ? <repositories>
? ? ? ? ? ? ? ? <repository>
? ? ? ? ? ? ? ? ? ? <id>releases</id>
? ? ? ? ? ? ? ? ? ? <url>http://xxxxxx</url>
? ? ? ? ? ? ? ? ? ? <releases>
? ? ? ? ? ? ? ? ? ? ? ? <enabled>true</enabled>
? ? ? ? ? ? ? ? ? ? </releases>
? ? ? ? ? ? ? ? ? ? <snapshots>
? ? ? ? ? ? ? ? ? ? ? ? <enabled>true</enabled>
? ? ? ? ? ? ? ? ? ? </snapshots>
? ? ? ? ? ? ? ? </repository>
? ? ? ? ? ? </repositories>
? ? ? ? ? ? <pluginRepositories>
? ? ? ? ? ? ? ? <pluginRepository>
? ? ? ? ? ? ? ? ? ? <id>rep-plugin</id>
? ? ? ? ? ? ? ? ? ? <url>http://xxxxxxxx</url>
? ? ? ? ? ? ? ? ? ? <releases>
? ? ? ? ? ? ? ? ? ? ? ? <enabled>true</enabled>
? ? ? ? ? ? ? ? ? ? </releases>
? ? ? ? ? ? ? ? ? ? <snapshots>
? ? ? ? ? ? ? ? ? ? ? ? <enabled>true</enabled>
? ? ? ? ? ? ? ? ? ? </snapshots>
? ? ? ? ? ? ? ? </pluginRepository>
? ? ? ? ? ? </pluginRepositories>
? ? ? ? </profile>
? ? <!-- profile
? ? ?| Specifies a set of introductions to the build process, to be activated using one or more of the
? ? ?| mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
? ? ?| or the command line, profiles have to have an ID that is unique.
? ? ?|
? ? ?| An encouraged best practice for profile identification is to use a consistent naming convention
? ? ?| for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
? ? ?| This will make it more intuitive to understand what the set of introduced profiles is attempting
? ? ?| to accomplish, particularly when you only have a list of profile id's for debug.
? ? ?|
? ? ?| This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
? ? <profile>
? ? ? <id>jdk-1.4</id>
? ? ? <activation>
? ? ? ? <jdk>1.4</jdk>
? ? ? </activation>
? ? ? <repositories>
? ? ? ? <repository>
? ? ? ? ? <id>jdk14</id>
? ? ? ? ? <name>Repository for JDK 1.4 builds</name>
? ? ? ? ? <url>http://www.myhost.com/maven/jdk14</url>
? ? ? ? ? <layout>default</layout>
? ? ? ? ? <snapshotPolicy>always</snapshotPolicy>
? ? ? ? </repository>
? ? ? </repositories>
? ? </profile>
? ? -->
? ? <!--
? ? ?| Here is another profile, activated by the system property 'target-env' with a value of 'dev',
? ? ?| which provides a specific path to the Tomcat instance. To use this, your plugin configuration
? ? ?| might hypothetically look like:
? ? ?|
? ? ?| ...
? ? ?| <plugin>
? ? ?| ? <groupId>org.myco.myplugins</groupId>
? ? ?| ? <artifactId>myplugin</artifactId>
? ? ?| ??
? ? ?| ? <configuration>
? ? ?| ? ? <tomcatLocation>${tomcatPath}</tomcatLocation>
? ? ?| ? </configuration>
? ? ?| </plugin>
? ? ?| ...
? ? ?|
? ? ?| NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
? ? ?| ? ? ? anything, you could just leave off the <value/> inside the activation-property.
? ? ?|
? ? <profile>
? ? ? <id>env-dev</id>
? ? ? <activation>
? ? ? ? <property>
? ? ? ? ? <name>target-env</name>
? ? ? ? ? <value>dev</value>
? ? ? ? </property>
? ? ? </activation>
? ? ? <properties>
? ? ? ? <tomcatPath>/path/to/tomcat/instance</tomcatPath>
? ? ? </properties>
? ? </profile>
? ? -->
? </profiles>
? <!-- activeProfiles
? ?| List of profiles that are active for all builds.
? ?|
? ?激活指定的環(huán)境
? <activeProfiles>
? ? <activeProfile>alwaysActiveProfile</activeProfile>
? ? <activeProfile>anotherAlwaysActiveProfile</activeProfile>
? </activeProfiles>
? -->
? ? <activeProfiles>
? ? ? ? <activeProfile>env1</activeProfile>
? ? </activeProfiles>
</settings>

到此這篇關(guān)于Maven下載依賴的順序及配置文件小結(jié)的文章就介紹到這了,更多相關(guān)Maven下載依賴順序內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • SpringBoot如何獲取src/main/resource路徑下的文件

    SpringBoot如何獲取src/main/resource路徑下的文件

    這篇文章主要介紹了SpringBoot如何獲取src/main/resource路徑下的文件,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2021-12-12
  • Spring Boot緩存問題分析及解決方案

    Spring Boot緩存問題分析及解決方案

    SpringBoot提供緩存支持,提升應(yīng)用性能,但可能出現(xiàn)緩存不一致、緩存穿透、緩存擊穿等問題,分析了緩存基本概念、SpringBoot緩存支持、常見緩存問題及解決方案,感興趣的朋友跟隨小編一起看看吧
    2024-09-09
  • Maven install 報錯

    Maven install 報錯"程序包不存在"問題的解決方法

    這篇文章主要介紹了Maven install 報錯"程序包不存在"問題的解決方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • Java SerialVersionUID作用詳解

    Java SerialVersionUID作用詳解

    這篇文章主要介紹了Java SerialVersionUID作用詳解,本篇文章通過簡要的案例,講解了該項技術(shù)的了解與使用,以下就是詳細內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • 10分鐘搞定Java并發(fā)隊列

    10分鐘搞定Java并發(fā)隊列

    這篇文章主要介紹了Java并發(fā)隊列,對此感興趣的同學(xué),可以參考下
    2021-04-04
  • Java設(shè)計模式之備忘錄模式

    Java設(shè)計模式之備忘錄模式

    這篇文章主要介紹了Java設(shè)計模式之備忘錄模式,備忘錄模式(Memento Pattern),屬于行為型設(shè)計模式,目的是用于保存一個對象在某一時刻的狀態(tài),以便于在將來某個時刻根據(jù)此狀態(tài)恢復(fù)該對象,需要的朋友可以參考下
    2023-12-12
  • Java中Map.entry的具體使用

    Java中Map.entry的具體使用

    Map.Entry?是Map中的一個接口,Map.Entry里有相應(yīng)的getKey和getValue方法,讓我們能夠從一個項中取出Key和Value,本文就詳細的介紹一下Map.entry的具體使用,感興趣的可以了解一下
    2023-05-05
  • JSON--List集合轉(zhuǎn)換成JSON對象詳解

    JSON--List集合轉(zhuǎn)換成JSON對象詳解

    這篇文章主要介紹了List集合轉(zhuǎn)換成JSON對象,小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。
    2017-01-01
  • Java跳出當前的多重嵌套循環(huán)的五種方法

    Java跳出當前的多重嵌套循環(huán)的五種方法

    在Java編程中,跳出多重嵌套循環(huán)可以使用break語句、標號與break組合、return語句、標志變量和異常處理五種方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2024-10-10
  • 微服務(wù)鏈路追蹤Spring Cloud Sleuth整合Zipkin解析

    微服務(wù)鏈路追蹤Spring Cloud Sleuth整合Zipkin解析

    這篇文章主要為大家介紹了微服務(wù)鏈路追蹤Spring Cloud Sleuth整合Zipkin解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-02-02

最新評論