简体   繁体   中英

How can I make maven to use maven cetral repo?

So my default maven settings.xml file in my ~/.m2/ folder is containing links to my work repositories. So whenever I run an install on my pom.xml's it try to fetch from the corp nexus maven repositories.

For a hobby project which I am just starting with I don't want to make use of the corp maven nexus, but to make use of the central maven repo. I don't want to replace the entire settings.xml as this would mean reloading the entire local maven repo once I switch back to my corp work.

How can I achieve this ?

Add the following as your first repository in the repositories tag in the settings.xml

        <repository>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
            <id>central</id>
            <url>http://repo1.maven.org/maven2</url>
        </repository>

You may also want to use profiles . But, that is not a requirement.

You can also add a repository on your pom

<repositories>
    <repository>
    <id>central</id>
    <url>http://rep1.maven.org/maven2</url>
    </repository>
</repositories>

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