欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Java?Maven?Settings配置參考教程

 更新時間:2023年09月11日 10:50:37   作者:授客  
這篇文章主要介紹了Java?Maven?Settings配置參考,本文通過示例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下

介紹

快速概覽

settings.xml文件中的 settings 元素包含用于定義以各種方式配置Maven執(zhí)行的值的元素,如pom.xml,但不應綁定到任何特定項目或分發(fā)給受眾。這些值包括本地倉庫位置、備用遠程倉庫服務器和身份驗證信息。

settings.xml文件可能位于兩個地方:

  • Maven安裝:${maven.home}/conf/settings.xml

  • 用戶安裝:${user.home}/.m2/settings.xml

前者的 settings.xml也稱為全局設置,后者的 settings.xml稱為用戶設置。如果這兩個文件都存在,它們的內(nèi)容就會被合并,而用戶特定的 settings.xml占主導地位。

提示:如果您需要從頭開始創(chuàng)建特定于用戶的設置,最簡單的方法是將全局設置從Maven安裝位置復制到${user.home}/.m2目錄中。Maven的默認 settings.xml是一個包含注釋和示例的模板,因此你可以快速調整它以滿足您的需求。

以下是settings下的頂級元素概述:

<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository/>
  <interactiveMode/>
  <offline/>
  <pluginGroups/>
  <servers/>
  <mirrors/>
  <proxies/>
  <profiles/>
  <activeProfiles/>
</settings>

settings.xml的內(nèi)容可以使用以下表達式進行插值(interpolated):

1.${user.home}和所有其他系統(tǒng)屬性(自Maven 3.0以來)

2.${env.HOME}等環(huán)境變量

請注意,在settings.xml 中的profiles中定義的屬性不能用于插值。

一個簡單配置示例

<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <localRepository>D:\maven-repo</localRepository>
    <servers>
        <server>
            <username>testUser</username>
            <password>APBNwz5vH2BK2Et9ujKQsWQQ245</password>
            <id>central</id>
        </server>
        <server>
            <username>testUser</username>
            <password>APBNwz5vH2BK2Et9ujKQsWQQ245</password>
            <id>snapshots</id>
        </server>
    </servers>
    <mirrors>
        <mirror>
            <mirrorOf>*</mirrorOf>
            <name>maven</name>
            <url>https://artifactory.example.com/artifactory/maven</url>
            <id>maven</id>
        </mirror>
    </mirrors>
    <profiles>
        <profile>
            <repositories>
                <repository>
                    <id>nexus-aliyun</id>
                    <name>nexus-aliyun</name>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>maven</name>
                    <url>https://artifactory.example.com/artifactory/maven</url>
                </repository>
                <repository>
                    <snapshots />
                    <id>snapshots</id>
                    <name>maven</name>
                    <url>https://artifactory.example.com/artifactory/maven</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>alimaven</id>
                    <name>aliyun maven</name>
                    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                </pluginRepository>
                <pluginRepository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>maven</name>
                    <url>https://artifactory.example.com/artifactory/maven</url>
                </pluginRepository>
                <pluginRepository>
                    <snapshots />
                    <id>snapshots</id>
                    <name>maven</name>
                    <url>https://artifactory.example.com/artifactory/maven</url>
                </pluginRepository>
            </pluginRepositories>
            <id>artifactory</id>
        </profile>
        <profile>
            <id>jdk-1.8</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>artifactory</activeProfile>
    </activeProfiles>
</settings>

Settings明細

簡單值

頂級settings 元素的一半是簡單值,表示一系列值,這些值描述了構建系統(tǒng)中一直處于激活(active full-time)的元素

<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>${user.home}/.m2/repository</localRepository>
  <interactiveMode>true</interactiveMode>
  <offline>false</offline>
  ...
</settings>
  • localRepository: 該元素值是該構建系統(tǒng)的本地倉庫的路徑。默認值為${user.home}/.m2/repository。該元素對于允許所有登錄用戶從公共本地倉庫進行構建的主服務器構建特別有用。

  • interactiveMode: 如果Maven應該嘗試與用戶交互以獲取輸入則設置為true,否則為false。默認為true

  • offline: 如果此生成系統(tǒng)應在脫機模式下運行則設置為true,否則為false。默認為false。該元素對于由于網(wǎng)絡設置或安全原因而無法連接到遠程倉庫的服務器構建非常有用。

插件組(Plugin Groups)

此元素包含一個 pluginGroup 元素列表,每個元素都包含一個組ID。當用到某個插件并且命令行中沒有提供該插件組件ID時,會搜索該列表。此列表自動包含org.apache.maven.pluginsorg.codehaus.mojo

<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <pluginGroups>
    <pluginGroup>org.eclipse.jetty</pluginGroup>
  </pluginGroups>
  ...
</settings>

例如,跟進上述給定的設置,Maven命令行可以使用截斷的命令執(zhí)行org.eclipse.jetty:jetty-Maven plugin:run

mvn jetty:run

服務器(Servers)

由POM的repositions和distributionManagement元素定義的,用于下載和發(fā)布的倉庫。但是,某些設置(如 username 和password )不應與 pom.xml一起分發(fā)。此類信息應存在于 settings.xml中的生成服務器上。

<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <servers>
    <server>
      <id>server001</id>
      <username>my_login</username>
      <password>my_password</password>
      <privateKey>${user.home}/.ssh/id_dsa</privateKey>
      <passphrase>some_passphrase</passphrase>
      <filePermissions>664</filePermissions>
      <directoryPermissions>775</directoryPermissions>
      <configuration></configuration>
    </server>
  </servers>
  ...
</settings>
  • id: 這是與Maven試圖連接的,與倉庫/鏡像的 id 元素匹配的服務器(而不是要登錄的用戶)的ID。
  • usernamepassword: 這兩元素成對出現(xiàn),分別表示對此服務器進行身份驗證所需的登錄名和密碼。
  • privateKeypassphrase: 類似前兩個元素,這對元素指定私鑰(默認為 ${user.home}/.ssh/id_dsa)和passphrase的路徑,如果必要的話。passphrase 和password元素將來可能會外部化,但目前它們必須在settings.xml文件中設置為純文本。
  • filePermissionsdirectoryPermissions: 在發(fā)布時創(chuàng)建倉庫文件或目錄時,需要使用的權限。每個的合法值是一個三位數(shù),對應于*nix文件權限,例如664或775。

注意:如果使用私鑰登錄服務器,請確保省略<password> 元素。否則,該鍵將被忽略。

密碼加密

2.1.0+中添加了一項新功能-服務器密碼和passphrase加密。詳情請查閱https://maven.apache.org/guides/mini/guide-encryption.html

鏡像(Mirrors)

<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <mirrors>
    <mirror>
      <id>planetmirror.com</id>
      <name>PlanetMirror Australia</name>
      <url>http://downloads.planetmirror.com/pub/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>
  • idname: 分別表示此鏡像的唯一標識符和用戶友好的名稱。 id用于區(qū)分mirror元素,以及連接到鏡像時,用于從servers 中選擇相應的憑據(jù)。
  • url: 鏡像的基礎URL。構建系統(tǒng)將使用此URL連接到倉庫,而不是原始倉庫的URL。
  • mirrorOf: 設置要被鏡像的倉庫id。例如,如需指向Mavencenter倉庫(https://repo.maven.apache.org/maven2/)的鏡像,設置該元素值為center。更高級的映射,如repo1,repo2*,!inhouse也是可以的。該配置值一定與鏡像id不同。

有關鏡像的更深入介紹,請閱讀鏡像設置指南

鏡像設置指南

為倉庫使用鏡像

擁有倉庫,你可以指定要從哪個位置下載某些工件,例如依賴項和maven插件??梢?a rel="external nofollow" target="_blank">在項目內(nèi)部聲明倉庫,這意味著,如果你有自己的自定義倉庫,那些共享你項目的可以很容易地獲得開箱即用的正確配置。但是,你可能希望在不更改項目文件的情況下為特定倉庫使用備用鏡像。

使用鏡像的一些原因是:

  • 互聯(lián)網(wǎng)上有一個同步鏡像,地理位置更近、速度更快
  • 希望用自己的內(nèi)部倉庫替換特定的倉庫,可以對其進行更大的控制
  • 想運行倉庫管理器為鏡像提供本地緩存,而需要使用其URL

可以簡單的把mirror理解為一個攔截器,攔截maven對遠程repository的相關請求,然后把請求里的remote repository地址,重定向到mirror里配置的地址,如下

未配置鏡像前:

配置鏡像之后:

要為給定倉庫配置鏡像,需在配置文件(${user.home}/.m2/settings.xml)中提供它,為新倉庫指定自己的idurl,并指定mirrorOf設置,即被鏡像的倉庫ID。例如,默認情況下包含的Maven Central主倉庫的ID為central,因此要使用不同的鏡像實例,需要配置以下內(nèi)容:

<settings>
  ...
  <mirrors>
    <mirror>
      <id>other-mirror</id>
      <name>Other Mirror Repository</name>
      <url>https://other-mirror.repo.other-company.com/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>

注意,對于給定的倉庫,最多可以有一個鏡像。換句話說,不能將單個倉庫映射到一組定義相同<mirrorOf>值的鏡像。Maven不會聚合鏡像,而是簡單地選擇第一個匹配的鏡像。如果要提供多個倉庫的組合視圖,請使用倉庫管理器

settings.xml述符文檔查閱https://maven.apache.org/ref/3.9.3/maven-settings/settings.html

:Maven的官方倉庫位于https://repo.maven.apache.org/maven2由Sonatype公司托管,并通過CDN在全球范圍內(nèi)分發(fā)。

倉庫Metadata中提供了已知鏡像的列表。這些鏡像可能沒有相同的內(nèi)容,我們不以任何方式支持它們。

使用單個倉庫

可以通過讓Maven鏡像所有倉庫請求來強制它使用單個倉庫。倉庫必須包含所有所需的工件,或者能夠將請求代理到其他倉庫。當使用具有代理外部請求的Maven 倉庫管理器的內(nèi)部公司倉庫時,此設置最有用。

為此,請將 mirrorOf設置為*。

注意:此功能僅在Maven 2.0.5+中可用。

<settings>
  ...
  <mirrors>
    <mirror>
      <id>internal-repository</id>
      <name>Maven Repository Manager running on repo.mycompany.com</name>
      <url>http://repo.mycompany.com/proxy</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>

高級設置

單個鏡像可以處理多個倉庫。這通常與倉庫管理器結合使用,后者可以方便地集中配置鏡像背后的倉庫列表。

語法:

  • *匹配所有倉庫ID。
  • external:*匹配除使用localhost或基于文件的倉庫以外的所有倉庫。當希望排除為集成測試定義的重定向倉庫時,使用此選項。
  • 從Maven 3.8.0開始, external:http:* 匹配使用localhost除外,所有使用HTTP的倉庫
  • 可以使用逗號作為分隔符指定多個倉庫
  • 感嘆號可以與上述通配符之一一起使用,以排除倉庫id

注意不要在逗號分隔列表中的標識符或通配符周圍包含額外的空格。例如,將<mirrorOf>設置為!repo1, *不會鏡像任何內(nèi)容,而!repo1,*將鏡像除repo1之外的所有內(nèi)容。

通配符在以逗號分隔的倉庫標識符列表中的位置并不重要,因為通配符會推遲進一步處理,并且顯式包含或排除會停止處理,從而否決任何通配符匹配(原文:The position of wildcards within a comma separated list of repository identifiers is not important as the wildcards defer to further processing and explicit includes or excludes stop the processing, overruling any wildcard match)。

當您使用高級語法并配置多個鏡像時,聲明順序很重要。當Maven查找某個倉庫的鏡像時,它首先檢查<mirrorOf>與倉庫標識符完全匹配的鏡像。如果沒有找到直接匹配,Maven會根據(jù)上面的規(guī)則(如果有的話)選擇第一個匹配的鏡像聲明。因此,可以通過更改settings.xml中定義的順序來影響匹配順序

示例:

  • *=所有倉庫

  • external:*=所有不在本地主機上且不基于文件的內(nèi)容。

  • repo,repo1 = repo 或者repo1

  • *,!repo1 = 除repo1的所有倉庫

<settings>
  ...
  <mirrors>
    <mirror>
      <id>internal-repository</id>
      <name>Maven Repository Manager running on repo.mycompany.com</name>
      <url>http://repo.mycompany.com/proxy</url>
      <mirrorOf>external:*,!foo</mirrorOf>
    </mirror>
    <mirror>
      <id>foo-repository</id>
      <name>Foo</name>
      <url>http://repo.mycompany.com/foo</url>
      <mirrorOf>foo</mirrorOf>
    </mirror>
  </mirrors>
  ...
</settings>

創(chuàng)建自己的鏡像

central倉庫的大小正在穩(wěn)步增加。為了節(jié)省帶寬和你的時間,不允許鏡像整個central倉庫(如果這樣做會被自動禁止)相反,建議設置一個倉庫管理器 作為代理。

代理(Proxies)

<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <proxies>
    <proxy>
      <id>myproxy</id>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.somewhere.com</host>
      <port>8080</port>
      <username>proxyuser</username>
      <password>somepassword</password>
      <nonProxyHosts>*.google.com|ibiblio.org</nonProxyHosts>
    </proxy>
  </proxies>
  ...
</settings>
  • id: 此代理的唯一標識符。這用于區(qū)分proxy 元素。

  • activetrue 如果此代理處于活動狀態(tài),則為true 。這對于聲明一組代理很有用,但一次只能有一個代理處于活動狀態(tài)。

  • protocolhostport: 代理的 protocol://host:port,分隔成單個元素

  • usernamepassword: 這些元素成對出現(xiàn),表示對此代理服務器進行身份驗證所需的登錄名和密碼

  • nonProxyHosts: 這是不應使用代理的主機列表。列表的分隔符是代理服務器的預期類型;上面的例子是管道分隔的,逗號分隔也是常見的。

Profiles

settings.xml中的profile 元素是 pom.xml profile 元素的“裁剪”版本。它由activationrepositoriespluginRepositories 和 properties 元素組成。 profile元素只包括這四個元素,因為它們關注的是整個構建系統(tǒng)(即settings.xml文件的作用),而不是單個項目對象模型設置。

如果一個settings.xml中的profile被激活,它的值會覆蓋任何其它定義在pom.xmlprofiles.xml中帶有相同ID的profile。

Activation

Activations是配置文件的關鍵。與POM的profiles一樣,profile的力量來自于它僅在特定情況下修改某些值的能力;這些情況是通過<activation>元素指定的。

<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <profiles>
    <profile>
      <id>test</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <jdk>1.5</jdk>
        <os>
          <name>Windows XP</name>
          <family>Windows</family>
          <arch>x86</arch>
          <version>5.1.2600</version>
        </os>
        <property>
          <name>mavenVersion</name>
          <value>2.0.3</value>
        </property>
        <file>
          <exists>${basedir}/file2.properties</exists>
          <missing>${basedir}/file1.properties</missing>
        </file>
      </activation>
      ...
    </profile>
  </profiles>
  ...
</settings>

當滿足所有指定的條件時,將激活profile,但并非需要同時滿足所有條件。

  • jdkactivation在 jdk 元素中有一個內(nèi)置的、以Java為中心的檢查。如果在與給定版本前綴匹配的jdk版本號下運行測試,這將激活profile。在上面的示例中,1.5.0_06將匹配給定前綴即1.5。也支持范圍。請參閱maven enforcer插件獲取有關支持范圍的更多詳細信息。

  • osos元素可以定義上面顯示的一些特定于操作系統(tǒng)的屬性。請參閱maven enforcer插件獲取有關操作系統(tǒng)值的更多詳細信息。

  • property:如果Maven檢測到相應的name=value 對的屬性(一個可以在pom.xml中通過 ${name}間接引用的值),則 profile 將被激活。

  • file:最后,可通過給定文件名對應文件的 existence 或者missing激活 profile

activation 元素并不是激活profile的唯一方式。 settings.xml文件的activeProfile 元素可能包含profile的id。它們也可以通過命令行,通過 -P 標志后的逗號分隔列表(例如 -P test)顯式激活。

要查看哪個配置文件將在某個構建中激活,請使用maven-help-plugin

mvn help:active-profiles

屬性(Properties)

Maven properties是值占位符,類似于Ant中的properties。通過使用表示法 ${X},可以在POM中的任何位置訪問它們的值,其中 X 是屬性。它們有五種不同的形式,都可以從settings.xml文件中訪問:

  • env.X: 在變量前面加上“env.”前綴,將返回shell的環(huán)境變量。例如,${env.PATH} 包含$path環(huán)境變量(在Windows中為%PATH%)。
  • project.x: POM中.分路徑包含相應元素的值。例如:可通過 ${project.version}獲取1.0。
  • settings.xsettings.xml 中的.分路徑包含相應元素的值。例如可通過${settings.offline}得到false 值。
  • Java 系統(tǒng)屬性: 所有屬性,可通過java.lang.System.getProperties() 獲取并可作為POM properties,比如 ${java.home}.
  • x: 在某個<properties />元素或者某個外部文件中設置, 其值可能被用作${someVar}
<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <profiles>
    <profile>
      ...
      <properties>
        <user.install>${user.home}/our-project</user.install>
      </properties>
      ...
    </profile>
  </profiles>
  ...
</settings>

如果profile被激活的話,可通過POM訪問屬性${user.install}

倉庫(Repositories)

Repositories 是Maven用來填充構建系統(tǒng)的本地倉庫的遠程項目集合。Maven將其稱為插件和依賴項的正是來自該本地倉庫。不同的遠程倉庫可能包含不同的項目,profile激活的情況下,可以搜索它們以查找匹配的release或snapshot工件

<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <profiles>
    <profile>
      ...
      <repositories>
        <repository>
          <id>codehausSnapshots</id>
          <name>Codehaus Snapshots</name>
          <releases>
            <enabled>false</enabled>
            <updatePolicy>always</updatePolicy>
            <checksumPolicy>warn</checksumPolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>never</updatePolicy>
            <checksumPolicy>fail</checksumPolicy>
          </snapshots>
          <url>http://snapshots.maven.codehaus.org/maven2</url>
          <layout>default</layout>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>myPluginRepo</id>
          <name>My Plugins repo</name>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <url>https://maven-central-eu....com/maven2/</url>
        </pluginRepository>
      </pluginRepositories>
      ...
    </profile>
  </profiles>
  ...
</settings>
  • releasessnapshots: 這些是針對每種類型的工件,Release 或snapshot的策略。有了這兩個集合,POM就有能力在單個倉庫中獨立于其他類型來更改每種類型的策略。例如,可能出于開發(fā)目的,可以決定只啟用snapshot下載。
  • enabledtrue or false ,以確定是否為相應類型(releases or snapshots)啟用此倉庫。
  • updatePolicy: 此元素指定嘗試進行更新的頻率。Maven將本地POM的時間戳(存儲在倉庫的Maven元數(shù)據(jù)文件中)與遠程POM進行比較。選項為: alwaysdaily (默認)、或者interval:X(其中X是以分鐘為單位的整數(shù))或never。
  • checksumPolicy: 當Maven將文件發(fā)布到倉庫時,它還會發(fā)布相應的校驗和文件。關于丟失或不正確的校驗和時,可以選擇 ignore、fail或 warn 。
  • layout: 在上面對倉庫的描述中,有人提到它們都遵循一個通用的布局。這基本上是正確的。Maven2有一個默認的倉庫布局;然而,Maven1.x有一個不同的布局。使用此元素指定是default還是 legacy

插件倉庫(Plugin Repositories)

倉庫是兩種主要類型的工件的所在地。第一種是用作其他工件的依賴項的工件。這些是位于中心的大多數(shù)工件。另一種類型的工件是插件。Maven插件本身就是一種特殊類型的工件。正因為如此,插件倉庫可能會與其他倉庫分離(盡管,我還沒有聽到這樣做的令人信服的論據(jù))。在任何情況下, pluginRepositories 元素塊的結構都類似于 repositories 元素。 pluginRepository元素分別指定Maven可以在其中查找新插件的遠程位置。

激活Profiles(Active Profiles)

<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 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  ...
  <activeProfiles>
    <activeProfile>env-test</activeProfile>
  </activeProfiles>
</settings>

settings.xml謎題的最后一塊是activeProfiles 元素。它包含一系列activeProfiles 元素,每個元素的值都有一個 profile id。任何定義為activeProfileprofile id 都將處于活動狀態(tài),而與任何環(huán)境設置無關。如果沒有找到匹配的profile,則什么也不會發(fā)生。例如,如果env-test為一個activeProfile,一個在具有相應idpom.xml(或profile.xml)將處于活動狀態(tài)。如果找不到這樣的profile,則執(zhí)行將照常進行。

參考鏈接

https://maven.apache.org/settings.html

https://maven.apache.org/ref/3.9.3/maven-settings/settings.html

到此這篇關于Java Maven Settings配置參考的文章就介紹到這了,更多相關Java Maven Settings配置內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

  • Fluent Mybatis零xml配置實現(xiàn)復雜嵌套查詢

    Fluent Mybatis零xml配置實現(xiàn)復雜嵌套查詢

    本文主要介紹了Fluent Mybatis零xml配置實現(xiàn)復雜嵌套查詢,文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • springmvc+mybatis 做分頁sql 語句實例代碼

    springmvc+mybatis 做分頁sql 語句實例代碼

    本文通過一段實例代碼給大家介紹了springmvc+mybatis 做分頁sql 語句的方法,代碼簡單易懂,非常不錯,具有參考借鑒價值,需要的朋友參考下吧
    2017-07-07
  • MyBatisPlus+SpringBoot實現(xiàn)樂觀鎖功能詳細流程

    MyBatisPlus+SpringBoot實現(xiàn)樂觀鎖功能詳細流程

    樂觀鎖是針對一些特定問題的解決方案,主要解決丟失更新問題,下面這篇文章主要給大家介紹了關于MyBatisPlus+SpringBoot實現(xiàn)樂觀鎖功能的相關資料,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下
    2023-03-03
  • 詳解mybatis通過mapper接口加載映射文件

    詳解mybatis通過mapper接口加載映射文件

    本篇文章主要介紹了mybatis通過mapper接口加載映射文件 ,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-08-08
  • 詳解Java反射各種應用

    詳解Java反射各種應用

    Java除了給我們提供在編譯期得到類的各種信息之外,還通過反射讓我們可以在運行期間得到類的各種信息。通過反射獲取類的信息,得到類的信息之后,就可以獲取很多相關內(nèi)容。下面跟著小編一起來看下吧
    2017-01-01
  • SWT(JFace)體驗之模擬BorderLayout布局

    SWT(JFace)體驗之模擬BorderLayout布局

    SWT(JFace)體驗之模擬BorderLayout布局代碼。
    2009-06-06
  • 淺析Spring Security登錄驗證流程源碼

    淺析Spring Security登錄驗證流程源碼

    這篇文章主要介紹了Spring Security登錄驗證流程源碼解析,本文結合源碼講解登錄驗證流程,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-11-11
  • java 將數(shù)據(jù)加載到內(nèi)存中的操作

    java 將數(shù)據(jù)加載到內(nèi)存中的操作

    這篇文章主要介紹了java 將數(shù)據(jù)加載到內(nèi)存中的操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-09-09
  • spring?boot集成smart-doc自動生成接口文檔詳解

    spring?boot集成smart-doc自動生成接口文檔詳解

    這篇文章主要介紹了spring?boot集成smart-doc自動生成接口文檔詳解,smart-doc是一款同時支持java?restful?api和Apache?Dubbo?rpc接口文檔生成的工具,smart-doc顛覆了傳統(tǒng)類似swagger這種大量采用注解侵入來生成文檔的實現(xiàn)方法
    2022-09-09
  • java計算自冪數(shù)和水仙花數(shù)

    java計算自冪數(shù)和水仙花數(shù)

    對于一個正整數(shù)而言,長度是n,如果它的各位上的數(shù)字的n次方之和正好等于它本身,那么我們稱這樣的數(shù)為自冪數(shù),下面使用JAVA實現(xiàn)這個方法
    2014-03-03

最新評論