網頁

2020/10/30

IntelliJ IDEA Maven使用自訂的Nexus repository settings xml

IntelliJ IDEA Maven使用自訂的Nexus repository setting.xml設定方式如下。

範例環境:

  • IntelliJ IDEA 2020.2.2 (Community Edition)

例如下面是Nexus repository的settings.xml設定檔,放在D:\Nexus

<?xml version="1.0" encoding="UTF-8"?>
<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">

    <pluginGroups>
    </pluginGroups>

    <proxies>
    </proxies>

    <servers>
            <server>
                <id>nexus</id>
                <username>abc</username>
                <password>123</password>
            </server>
    </servers>

    <mirrors>
    </mirrors>

    <profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <name>nexus-repository</name>
                    <url>http://192.168.12.121:8081/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <name>nexus-plugin-repository</name>
                    <url>http://192.168.12.121:8081/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
        
        <servers>
            <server>
                <id>nexus</id>
                <username>abc</username>
                <password>123</password>
            </server>
        </servers>

    </profiles>


    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>

</settings>

在IntelliJ IDEA的偏好設定的Build, Execution, Deployment -> Build Tools -> Maven中找到[User settings file]欄位,修改為D:\Nexus\settings.xml,套用後重新rebuild Maven專案即可。





沒有留言:

張貼留言