使用下圖作為參考,我目前有一些挑戰。
我正在嘗試從神器中為 Maven 生成 settings.xml 模板,以便我可以從神器下載我的 Maven 依賴項。這就是我想要做的。我不是想建立一個部署回購或其他任何東西。我只是想為 Maven 插件建立我的依賴代理。
我的 maven 存盤庫將從 maven Central 下載/快取,稱為“joeytest-maven-central-remote”。
當我在工件中單擊“設定我”時,會發生以下情況:
系統提示我選擇存盤庫。自然,我會簡單地選擇我剛剛設定的遠程倉庫。那就是我想從那里下載我的依賴項的地方。問題是,我做不到。這不是一個選擇。我必須創建另一個名為“joeytest-maven-dev-local”的存盤庫,這可能是我將我的 maven 工件部署到的東西,只是為了在這個下拉串列中選擇一些東西。為什么我不能只選擇我創建的遠程倉庫?這就是問題#1。
在配置選項卡中進一步向下移動,我現在被迫為發布/快照/插件發布/插件快照識別四 (4) 個虛擬存盤庫。為什么?這與我只想從這個遠程倉庫下載依賴項有什么關系?我了解虛擬回購的目的,但我現在絕對不想/不需要使用它們。它們不應該是便利/后勤功能,而不是必需的組件嗎?這就是問題#2。
這些問題是否簡化了設計不佳的“設定”GUI,并且我不需要輸入任何這些資訊。我可以簡單地獲取模板,洗掉所有不必要的東西,然后直接從我最初創建的遠程倉庫下載依賴項?
還是我完全錯過了一些先決條件,如果是這樣,有人可以解釋為什么需要這些組件才能下載 settingsl.xml 模板檔案?

提前致謝,
uj5u.com熱心網友回復:
既然我已經解決了這個問題,我將自己回答這個問題。希望這對其他人有幫助。
我對此非常感興趣,并想提供我的發現。在 artifactory 中,存盤庫選擇螢屏的右上角有一個“設定我”按鈕。在設定工件以下載 maven 依賴項時,在幾個在線資源中都提到了此按鈕作為起點。然而,在線文章沒有提到的是,這個按鈕用于生成一個模板,它允許的不僅僅是下載依賴項。它還為部署和使用虛擬工件存盤庫做好了準備。因此,為了使用此功能,您必須已經在工件中設定了一個部署存盤庫和至少一個虛擬存盤庫。這會產生一個錯誤的假設,即這些專案需要使用工件作為下載依賴項的代理。這是錯誤的。見下文。
您可以完全跳過這個“設定我”按鈕,直接在 Maven 端設定您的 settings.xml。這種方法對于初學者來說更干凈,更簡單。如果您需要 maven settings.xml 的起點,可以自由使用模板來啟動。這是一個作業示例模板,供您入門參考。
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<id>myRepository</id>
<username>JohnDoe</username>
<password>****</password>
</server>
<server>
<id>myPluginRepository</id>
<username>JohnDoe</username>
<password>****</password>
</server>
</servers>
<profiles>
<profile>
<id>artifactory_default_profile</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>myRepository</id>
<name>joeytest-maven-libs-virtual</name>
<url>https://artifactory.dev.{myorg}.com:443/artifactory/joeytest-maven-libs-virtual/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>myPluginRepository</id>
<name>joeytest-maven-libs-virtual</name>
<url>https://artifactory.dev.{myorg}.com:443/artifactory/joeytest-maven-libs-virtual/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory_default_profile</activeProfile>
</activeProfiles>
</settings>
這個模板做了兩件事:
- 禁用默認的 maven 中央下載位置,因此它不會被使用。
- 指示 Maven 使用 artifactory 為 Maven 構建下載所有內容。
All you require in order to use artifactory as a proxy for downloading dependencies is at least one remote repo created in artifactory, which has a valid URL to source artifacts from externally. Beyond that if you wish, you may create deployment repositories for your builds, and/or create virtual repositories to aggregate other artifactory repositories, but these steps are completely optional.
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/449650.html
