1. 程式人生 > >Maven私服—nexus的簡單使用

Maven私服—nexus的簡單使用

文章目錄

安裝

  • 下載映象

docker pull registry.cn-hangzhou.aliyuncs.com/sherry/nexus:3.13.0

  • 設定資料卷

docker volume create --name nexus-data

  • 啟動
docker run -d -p 8080:8081 --name nexus -v \
nexus-data:/nexus-data \
registry.cn-hangzhou.aliyuncs.com/sherry/nexus:3.13.0

啟動nexus映象,並將資料掛載到資料卷中

  • 登陸

預設登陸名密碼:admin/admin123

使用nexus私有倉庫

修改預設密碼

建立一個新倉庫

這裡建立了一個以阿里雲映象為中心的倉庫

基本使用

  • 怎麼使用私服的倉庫呢?

修改setting.xml

...
  <servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password
>
admin123</password> </server> </servers> ... <mirrors> <mirror> <id>nexus</id> <name>Nexus私有倉庫</name> <url>http://server4:8080/repository/maven-public/</url> </mirror> </mirrors> ...

這裡只需要配置一個mirror

節點,就可以使用我們的nexus倉庫了,server節點用於jar的上傳

上傳專案jar

在pom.xml中新增以下配置

    <distributionManagement>
        <repository>
            <id>nexus</id>
            <name>Nexus Repository</name>
            <url>http://localhost:8082/repository/maven-thiird/</url>
        </repository>
    </distributionManagement>
    <repositories>
        <repository>
            <id>nexus</id>
            <name>Nexus Repository</name>
            <url>http://localhost:8082/repository/maven-thiird/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <!--snapshots預設是關閉的,需要開啟  -->
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <build>
        <plugins>
            <plugin> <!-- 打jar包 -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.1</version>
                <configuration>
                    <excludes>
                        <exclude>**/*.properties</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

上傳第三方jar

手動上傳第三方jar,如oracle驅動