简体   繁体   中英

How to specify credentials for custom maven private repo

I have used this article ( https://gist.github.com/fernandezpablo85/03cf8b0cd2e7d8527063 ) for creating a custom maven repo, and it works. But now I have a problem with a private repo. How can I specify credentials for the private repo?

You can set in .m2/settings.xml file

Like This:

<settings>
    <servers>
        <server>
            <id>private-repo</id>
            <username>xyz</username>
            <password>${pass}</password>
        </server>
    </servers>
</settings>

And in pom.xml :

<project>
    ...
    <repositories>
        <repository>
            <id>private-repo</id>
            <url>${private-repo.url}</url>
        </repository>
    </repositories>
    ...
</project>

A settings.xml file is usually found in a couple of places:

  • Global settings in Mavens home directory: ${maven.home}/conf/settings.xml
  • User settings in the user's home: ${user.home}/.m2/settings.xml

If both files exist, their contents are merged. Configurations from the user settings take precedence.

If your settings doesn't apply you can try to override the default settings.xml file location by adding --settings flag to your mvn... command.

sources:

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