假設我在一個 url 上托管一個 JAR 文件,例如:https://raw.githubusercontent.com/async-java/jars/master/x.jar我怎樣才能告訴 Maven 使用這個 url 而不是默認的(到 Maven Central)?<dependencies> <dependency> <groupId>com.my</groupId> <artifactId>commons-deps</artifactId> <type>pom</type> </dependency></dependencies><dependencyManagement> <dependencies> <dependency> <groupId>...</groupId> <artifactId>...</artifactId> <type>pom</type> <scope>import</scope> </dependency> </dependencies></dependencyManagement>我假設在其中一個 xml 配置中的某個地方我們可以告訴 Maven 使用上面的 URL 嗎?有人知道這樣做的正確方法嗎?如果不清楚——我不想托管整個 Maven 存儲庫——我只想提供一個 .jar 文件。
2 回答

侃侃爾雅
TA貢獻1801條經驗 獲得超16個贊
jar 可以有不同的 URL——但這些 URL 需要托管 Maven 存儲庫。
添加更多存儲庫(除了隱式存在的 MavenCentral)的標準方法是將它們添加到settings.xml
. 也可以將它們添加到 POM 本身。
Maven 存儲庫不必是 Nexus/Artifactory。但重要的是,URL 以標準方式反映 groupId、artifactId、version 等。

慕絲7291255
TA貢獻1859條經驗 獲得超6個贊
我在我的 pom.xml 中使用它來引用不是 maven 中心的共享 maven 存儲庫。
<repositories>
<repository>
<id>my.maven.repository</id>
<url>https://mymavenrepo.com/jars/location</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
添加回答
舉報
0/150
提交
取消