简体   繁体   中英

Specify a specific repository url in maven settings.xml to deploy in Nexus

I'm a new guy on Maven and Nexus. I have a problem to deploy my maven project (developped with IntelliJ) on my local Nexus. You will find attached my maven settings.xml

My objective is to deploy my project without modify a pom.xml file, only the ~/.m2/settings.xml

I have tried the following command (which works) : $ mvn clean deploy -DaltDeploymentRepository=nexus::default:: http://192.168.1.8:8081/repository/maven-snapshots

But I want the same results with only : $ mvn clean deploy

Any idea ?

Thanks

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <mirrors>
        <mirror>
            <!--This sends everything else to /public -->
            <id>nexus</id>
            <mirrorOf>*</mirrorOf>
            <url>http://192.168.1.8:8081/repository/maven-public/</url>
        </mirror>
    </mirrors>
    <profiles>
        <profile>
            <id>nexus</id>
            <!--Enable snapshots for the built in central repo to direct -->
            <!--all requests to nexus via the mirror -->
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases><enabled>true</enabled></releases>
                    <snapshots><enabled>true</enabled></snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>



    </profiles>
    <activeProfiles>
        <!--make the profile active all the time -->
        <activeProfile>nexus</activeProfile>
    </activeProfiles>


    <servers>
        <server>
            <id>nexus</id>
            <username>admin</username>
            <password>******</password>
        </server>
    </servers>

</settings>

您可以将<properties>部分添加到settings.xml并添加

<altDeploymentRepository>nexus::default::http://192.168.1.8:8081/repository/maven-snapshots</altDeploymentRepository>

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