Docker Nexus搭建Maven Repository私服

来源:互联网 发布:mysql执行计划详解 编辑:程序博客网 时间:2024/06/03 12:29

发博词

公司用的电信的网,上个GitHub超慢,代码也clone不下来,maven也没法用,一个jar包经常下载不完整,不得已搭建一个maven私服。新版本的nexus已经不仅仅支持maven2了, nuget, raw, docker, npm等都支持了。

Docker 安装

比较简单,略。

配置

  1. 关闭匿名用户
    Settings-Security-Anonymous页面反选allow anonymous users to access the server。
  2. 添加开发者角色developer
    角色权限:
    1. nx-repository-view-*-*-read    2. nx-repository-view-maven2-maven-realeases-*,    3. nx-repository-view-maven2-maven-snapshots-*

拥有对所有库的读权限,和maven-realeases、maven-snapshots两个库的所有权限。
3. 添加开发者用户developer
填写用户信息,选择角色developer。
4. 本地maven安装实例配置

<?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">    <localRepository>D:\.m2\repository</localRepository>    <pluginGroups>    </pluginGroups>    <proxies>    </proxies>    <servers>        <server>            <id>nexus</id>            <username>****</username>            <password>****</password>        </server>    </servers>    <mirrors>        <mirror>            <id>nexus</id>            <mirrorOf>*</mirrorOf>            <url>http://47.93.159.139:8081/repository/maven-public/</url>        </mirror>    </mirrors>    <profiles>        <profile>            <id>nexus</id>            <repositories>                <repository>                    <id>central</id>                    <url>http://central</url>                    <releases>                        <enabled>true</enabled>                        <updatePolicy>always</updatePolicy>                    </releases>                    <snapshots>                        <enabled>true</enabled>                        <updatePolicy>always</updatePolicy>                    </snapshots>                </repository>            </repositories>            <pluginRepositories>                <pluginRepository>                    <id>central</id>                    <url>http://central</url>                    <releases>                        <enabled>true</enabled>                        <updatePolicy>always</updatePolicy>                    </releases>                    <snapshots>                        <enabled>true</enabled>                        <updatePolicy>always</updatePolicy>                    </snapshots>                </pluginRepository>            </pluginRepositories>        </profile>    </profiles>    <activeProfiles>        <activeProfile>nexus</activeProfile>    </activeProfiles></settings>
  1. Deploy配置
    在项目的POM文件中添加如下的内容
<distributionManagement>        <repository>            <id>nexus</id>            <name>Nexus Release Repository</name>            <url>http://47.93.159.139:8081/repository/maven-releases/</url>        </repository>        <snapshotRepository>            <id>nexus</id>            <name>Nexus Snapshot Repository</name>            <url>http://47.93.159.139:8081/repository/maven-snapshots/</url>        </snapshotRepository>    </distributionManagement>
原创粉丝点击