nexus的maven配置

nexus是可以搭建maven,npm,docker,pypi私有仓库的工具,本文记录maven的安装配置

配置nexus的maven

  • maven-aliyun-proxy

    1
    2
    Remote storage:http://maven.aliyun.com/nexus/content/groups/public
    Blob store:maven
  • maven-cloudera-proxy

    1
    2
    Remote storage:https://repository.cloudera.com/artifactory/cloudera-repos/
    Blob store:maven
  • maven-hosted-snapshots

    1
    2
    3
    Version policy: Snapshot
    Blob store:maven
    Deployment policy: Allow redeploy
  • maven-hosted-releases

    1
    2
    3
    Version policy: Release
    Blob store:maven
    Deployment policy: Allow redeploy
  • maven-times-group(注意Members顺序)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    Blob store:maven
    Members:
    - maven-aliyun-proxy
    - maven-cloudera-proxy
    - maven-hosted-releases
    - maven-hosted-snapshots
    - maven-central
    - maven-releases
    - maven-snapshots

配置本地maven

  • 全局配置

    • mac下brew的配置:/usr/local/Cellar/maven/3.5.2/libexec/conf/settings.xml
    • linux下的配置:$MAVEN_HOME/conf/settings.xml
  • 用户级别配置

    • ~/.m2/settings.xml(若没有需要新建)
  • settings.xml配置如下:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    <settings>
    <mirrors>
    <mirror>
    <!--This sends everything else to /public -->
    <id>nexus</id>
    <mirrorOf>*</mirrorOf>
    <url>http://ip:port/nexus/repository/maven-times-group/</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 username and password -->
    <server>
    <id>nexus-releases</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
    <server>
    <id>nexus-snapshot</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
    </servers>

    </settings>
  • 发布项目到nexus仓库配置

    在项目的pom.xml如下配置:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    <!--nexus 设置-->
    <distributionManagement>
    <repository>
    <id>nexus-releases</id>
    <name>Nexus Release Repository</name>
    <url>http://ip:port/nexus/repository/maven-hosted-releases/</url>
    </repository>
    <snapshotRepository>
    <id>nexus-snapshot</id>
    <name>Nexus Snapshot Repository</name>
    <url>http://ip:port/nexus/repository/maven-hosted-snapshots/</url>
    </snapshotRepository>
    </distributionManagement>
分享到