简体   繁体   English

Maven:是否可以将一组第三方罐子上传到存储库,然后将其作为单个依赖项引用?

[英]Maven: Is it possible to upload a set of 3rd party jars to repository, which can then be referenced as a single dependency?

We are using an internal Nexus Repository for third party jars which are dependencies in our applications. 我们正在将内部Nexus存储库用于第三方jar,这些第三方jar是我们应用程序中的依赖项。

I am starting a new project, and have a set of 4 third party jar files which I want to upload to Nexus, and then reference, ideally, as a single dependency (ie artifactId/version) from my project pom.xml. 我正在开始一个新项目,并有一组4个第三方jar文件,我希望将其上传到Nexus,然后理想情况下应作为我项目pom.xml中的单个依赖项(即工件ID /版本)进行引用。

These jars are always given together, never versioned separately, so having a separate artifactId/version combination for each jar is not useful. 这些jar总是一起提供的,永远不会单独进行版本控制,因此每个jar具有单独的artifactId / version组合是没有用的。 Is it possible to upload all the jars into a single artifact/version folder in Nexus, and then to reference them as a single dependency in my Maven project? 是否可以将所有罐子上传到Nexus中的单个工件/版本文件夹中,然后在我的Maven项目中将它们作为单个依赖项引用?

As you refer to in your comment, you can create a pom file of your own that depends on the four jars you talk about. 正如您在评论中提到的那样,您可以创建自己的pom文件,该文件取决于您谈论的四个jar。 Then, release this to your local nexus. 然后,将其释放到您的本地关系。 Once this is done, you can depend on it as a pom dependency, which will bring in the four libraries you want. 完成此操作后,您可以将其作为pom依赖项依赖,它将引入您想要的四个库。

I would use a custom property in the pom file to hold the version number, so that you can change the version once for all the dependencies. 我会在pom文件中使用自定义属性来保存版本号,以便您可以为所有依赖项一次更改版本。 For example: 例如:

<properties>
    <spring.version>3.1.2.RELEASE</spring.version>
</properties>

<dependencies>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency>

</dependencies>

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

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