zoukankan      html  css  js  c++  java
  • Maven(三) 基于Nexus搭建私服

    基于Nexus搭建私服

    1. 工作流程

    image-20200630062240096

    2. 仓库类型

    hosted

    私服仓库

    proxy仓库

    远程仓库

    group仓库

    组仓库,里面可以设置组合多个仓库。按顺序获取jar。

    3. 默认仓库

    安装好了Nexus后,会内置几个maven的默认仓库。可自定义仓库。

    maven-central

    proxy类型。maven中央库,默认从https://repo1.maven.org/maven2/拉取jar。

    maven-releases

    hosted类型。releases发行版版本仓库。

    maven-snapshots

    hosted类型。snapshots快照版版本仓库。

    maven-public

    group类型。默认把上面3个仓库组合在一起。

    注意:Nexus安装好以后需要更新远程仓库项目构建的索引文件。进入仓库就可以看到相关的按钮。

    4. 项目配置

    采用settings.xml中配置仓库的方式进行配置。

    settings.xml配置server
    <servers>
        <server>
            <id>release</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
        <server>
            <id>snapshot</id>
            <username>admin</username>
            <password>admin123</password>
        </server>
    </servers>
    
    项目pom.xml配置distributionManagement与server对应
    <distributionManagement>
        <repository>
            <id>release</id>
            <name>Release Repository</name>
            <!--地址,对应仓库属性中可以找到-->
            <url>http://xxx/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshot</id>
            <name>Snapshot Repository</name>
            <url>http://xxx/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
    
    settings.xml配置repository

    settings.xml中不能单独配置repository,基于profile进行配置。

    <profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <!--覆盖掉中央仓库-->
                    <id>central</id>
                    <name>nexus central</name>
                    <url>http://xxx/repository/maven-public/</url>
                    <layout>default</layout>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <!--快照版本,不从中央仓库拿-->
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <!--另外的仓库,会按照顺序进行查找-->
                <repository>
                    <id>releases</id>
                    <url>http://xxx/repository/maven-releases/</url>
                </repository>
                <repository>
                    <id>snapshots</id>
                    <url>http://xxx/repository/maven-snapshots/</url>
                </repository>
            </repositories>
            <!--配置插件下载的仓库-->
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
                <pluginRepository>
                    <id>snapshots</id>
                    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
    
  • 相关阅读:
    document.compatMode的CSS1compat
    js自运行函数
    Sublime Text 3 入门(插件控制台安装)
    javascript 面向对象技术
    jQuery ui 中文日历
    js给数字加三位一逗号间隔的两种方法(面试题)
    android eclipse集成环境
    中科红旗倒下,谁来挑战windows
    在网站制作中随时可用的10个 HTML5 代码片段
    IE6/IE7中li底部4px的Bug
  • 原文地址:https://www.cnblogs.com/lyldelove/p/13211494.html
Copyright © 2011-2022 走看看