美文网首页
六、配置Maven从nexus下载构件

六、配置Maven从nexus下载构件

作者: 编程界的小学生 | 来源:发表于2017-02-25 18:11 被阅读0次
1、单独项目配置(仅对当前项目生效,在pom如下定义)
<repositories>
    <repository>
        <id>nexus</id>
        <name>Nexus</name>
        <url>http://localhost/nexus-2.11/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>  
        <snapshots>
            <enabled>true</enabled>
        </snapshots>    
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
        <id>nexus</id>
        <name>Nexus</name>
        <url>http://localhost/nexus-2.11/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
  </pluginRepositories>
2、此电脑所有项目都默认从私服下载,需要改settings.xml
<profiles>
    <profile>
        <id>nexus</id>
        <repositories>
            <repository>
                <id>nexus</id>
                <name>Nexus</name>
                <url>http://localhost/nexus-2.11/content/groups/public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>nexus</id>
                <name>Nexus</name>
                <url>http://localhost/nexus-2.11/content/groups/public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>
    <!-- 每次建立maven都默认是jdk1.5的,此配置可以让建立maven项目默认jdk为1.7 -->
    <profile>
        <id>jdk-1.7</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>1.7</jdk>
        </activation>
        <properties>
            <maven.compiler.source>1.7</maven.compiler.source>
            <maven.compiler.target>1.7</maven.compiler.target>
            <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
        </properties>
    </profile>
  </profiles>
  <!-- 激活nexus的profile -->
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
说明:这个配置已经能让本机所有的maven项目从Nexus下载构件,但Maven还会不时地访问中央仓库centeral,可以配置一个镜像,地址为私服,这样maven对任何仓库的构件下载请求都会转到私服中,如下配置
<mirrors>
    <mirror>
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <name>Nexus</name>
        <url>http://localhost/nexus-2.11/content/groups/public/</url>
    </mirror>
  </mirrors>

若有兴趣,欢迎来加入群,【Java初学者学习交流群】:458430385,此群有Java开发人员、UI设计人员和前端工程师。有问必答,共同探讨学习,一起进步!
欢迎关注我的微信公众号【Java码农社区】,会定时推送各种干货:


qrcode_for_gh_577b64e73701_258.jpg

相关文章

  • 六、配置Maven从nexus下载构件

    1、单独项目配置(仅对当前项目生效,在pom如下定义) 2、此电脑所有项目都默认从私服下载,需要改settings...

  • Maven私服Nexus安装与使用

    Nexus介绍 Nexus是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库下载所需要的构件...

  • CentOS 7.2 搭建nexus私服

    Nexus 是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库 下载所需要的构件(artif...

  • Nexus搭建自己的Maven私服

    Nexus是Maven仓库管理器,管理开发所需要的构件。如果你每次都是从Apache提供的Maven中央仓库去下载...

  • Nexus3 私服的使用

    一、下载与安装 Maven Nexus3私服搭建指南,点击查看 二、Maven配置 打开Maven配置文件 set...

  • nexus的安装

    Nexus介绍 Nexus 是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库 下载所需要的...

  • maven学习笔记

    1.maven环境配置2.配置maven3.maven私服 nexus3 配置4.maven使用nexus仓库5....

  • Maven搭建私服Nexus

    一、搭建Maven私服,使用Nexus搭建1、下载Nexus,点击nexus下载,下载nexus-2.13.0-0...

  • 【Maven私服三】:使用maven私服下载构件

    使用maven私服下载构件 01.配置Maven的settings.xml 需要在< servers>节点中增加几...

  • Maven开发环境配置

    一、工具安装 nexus Maven Jdk eclipse 一、配置nexus maven-central T...

网友评论

      本文标题:六、配置Maven从nexus下载构件

      本文链接:https://www.haomeiwen.com/subject/gcrnwttx.html