• 使用Nexus配置Maven私有仓库


    1. 下载Nexus

    下载地址:http://nexus.sonatype.org/

    2. 启动Nexus

    nexus-2.0.6-bundle/nexus-2.0.6/bin/jsw/linux-x86-64/nexus 启动

    3. 进入Nexus管理页面

    http://localhost:8081/nexus/index.html

    默认密码 admin admin123

    点击Repositories ,可以看到仓库列表,包括下面几种:

    Public Repositories    仓库组 
    3rd part                     三方库,可以上传jar包到这个仓库
    Central                      maven中心仓库
    Releases                  自己项目中发布的构建 
    Snapshots                 trunk 下开发一个项目

    这里需要注意把Central 仓库的自动更新设置为True:


    更新之后能看到Index:


    4. 在settings.xml中使用本地仓库:

    ~/.m2 下新建settings.xml :

    Xml代码  收藏代码
    <profile>  
              <id>dev</id>  
              <repositories>  
              <repository>  
                <id>nexus</id>                                    
                     <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>                        
                <releases>  
                    <enabled>true</enabled>  
                    </releases>  
                <snapshots>  
                 <enabled>true</enabled>  
                </snapshots>  
                 </repository>  
              </repositories>  
              
             <pluginRepositories>  
      
                    <pluginRepository>  
      
                        <id>nexus</id>  
      
                        <url>http://127.0.0.1:8081/nexus/content/groups/public</url>  
      
                        <releases>  
      
                            <enabled>true</enabled>  
      
                        </releases>  
      
                        <snapshots>  
      
                            <enabled>true</enabled>  
      
                        </snapshots>  
      
                    </pluginRepository>  
      
                </pluginRepositories>  
      
            </profile>  
      </profiles>
    
       <activeProfiles>  
            <activeProfile>dev</activeProfile>  
       </activeProfiles> 

     方式二

    <profile>
          <id>dev</id>
          <activation>
            <jdk>1.7</jdk>
          </activation>
          <repositories>
            <repository>
              <id>devRepos</id>
              <name>dev Repository</name>
              <url>http://127.0.0.1:8081/nexus/content/repositories/devRepos/</url>
              <layout>default</layout>
            </repository>
          </repositories>
    </profile>

    现在可以通过maven实验一下:

    mvn archetype:create  -DgroupId=com.yourcompany -DartifactId=myproject  -DarchetypeArtifactId=maven-archetype-webapp

    lvkun@lvkun-duitang:~/workspace$ mvn archetype:create  -DgroupId=com.yourcompany -DartifactId=myproject  -DarchetypeArtifactId=maven-archetype-webapp 
    [INFO] Scanning for projects...
    Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom
    Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.pom (5 KB at 27.2 KB/sec)
    Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom
    Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-plugins/18/maven-plugins-18.pom (13 KB at 409.6 KB/sec)
    Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/maven-parent/16/maven-parent-16.pom
    Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/maven-parent/16/maven-parent-16.pom (23 KB at 463.8 KB/sec)
    Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/apache/7/apache-7.pom
    Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/apache/7/apache-7.pom (15 KB at 563.7 KB/sec)
    Downloading: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar
    Downloaded: http://127.0.0.1:8081/nexus/content/groups/public/org/apache/maven/plugins/maven-clean-plugin/2.4.1/maven-clean-plugin-2.4.1.jar (23 KB at 459.9 KB/sec)

  • 相关阅读:
    mssql⾥关于触发器关键字for和after的区别
    pl/sql导入、导出csv等格式文件
    从 Ctrl、Shift、Alt 键看中外差别(用哲学角度解释)
    formcreatedesigner一款开源的vue可视化表单设计器
    前端常见内存泄漏及解决方法
    使用NPM Scripts打造简单的自动化构建工作流
    关于AnyProxy
    单线程的Node.js是如何实现高并发的
    mysql存储emoji表情报错问题
    使用 MySQL Workbench 连接数据库时报错:SSL connection error: SSL is required but the server doesn't support it.
  • 原文地址:https://www.cnblogs.com/lvk618/p/4709511.html
Copyright © 2020-2023  润新知