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

╄→гoц情女王★ 提交于 2019-12-19 12:02:29

问题


We are using an internal Nexus Repository for third party jars which are dependencies in our applications.

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 (i.e. artifactId/version) from my project pom.xml.

These jars are always given together, never versioned separately, so having a separate artifactId/version combination for each jar is not useful. 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?


回答1:


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. 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.




回答2:


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. 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>


来源:https://stackoverflow.com/questions/23661856/maven-is-it-possible-to-upload-a-set-of-3rd-party-jars-to-repository-which-can

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!