简体   繁体   English

在 pom.xml maven 中添加远程存储库 jar 文件作为依赖项

[英]Adding remote repository jar file as dependency in pom.xml maven

Is it possible to add remote repository jar file ( https://repo.ah/lib/abc.jar ) in maven pom.xml as dependency in java project.是否可以在 maven pom.xml 中添加远程存储库 jar 文件( https://repo.ah/lib/abc.jar )作为 java 项目中的依赖项。 if so, can you please share example.如果是这样,你能分享一下例子吗?

No, it's not possible to add a complete repository as a dependency.不,不可能添加完整的存储库作为依赖项。 This doesn't make sense, because a repository can contain ten thousands of artifacts.这是没有意义的,因为一个存储库可以包含数以万计的工件。

If your project requires artifacts which are not hosted in the standard remote repository, you can specify this via the <repositories> tag in your pom.xml .如果您的项目需要不在标准远程存储库中托管的工件,您可以通过pom.xml<repositories>标记指定它。

<repositories>
    <repository>
        <id>vaadin-addons</id>
        <url>http://maven.vaadin.com/vaadin-addons</url>
    </repository>
    <repository>
        <id>vaadin-snapshots</id>
        <url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

More Informations:更多信息:
Introduction to Repositories 存储库简介
Setting up Multiple Repositories 设置多个存储库

In the comments you mentioned that the URL is an Artifactory.在您提到的评论中,该 URL 是一个 Artifactory。

So just add the Artifactory as <repository> to your settings.xml and then you can use the jar in your application.因此,只需将 Artifactory 作为<repository>添加到您的settings.xml ,然后您就可以在您的应用程序中使用该 jar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM