简体   繁体   中英

Retrieving dependencies from maven repository

So for my maven project I require jar dependencies that are available in public repositories and also jar dependencies that are on our company internal repository.

How do I configure my pom.xml so that I will retrieve the dependencies from public repositories and our company internal repository without synchronizing and uploading the stuff from public repos to the company internal repository.

In your settings.xml, which is usually in HOME_DIR/.m2 you need to add the company repository, maven central is included by default.

In the example below it will look for your artifact in each repo in order, starting with maven central.

   <profile>
        <id>extras</id>
        <repositories>
            <repository>
                <id>release</id>
                <name>libs-release</name>
                <url>http://internal.corp:8091/artifactory/libs-release</url>
            </repository>
            <repository>
                <id>snapshot</id>
                <name>libs-snapshot</name>
                <url>http://internal.corp:8091/artifactory/libs-snapshot-local</url>
            </repository>       
            <repository>
                <id>codelds</id>
                <url>https://code.lds.org/nexus/content/groups/main-repo</url>
            </repository>
            <repository>
                <id>spring-milestone</id>
                <name>Spring Maven MILESTONE Repository</name>
                <url>http://repo.springsource.org/libs-milestone</url>
            </repository>
        </repositories>
    </profile>

I would also say that I set up our corporate repository so that is has a virtual repository to maven central. This means as people use artifacts they will be stored in the company repository. This is normal practice.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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