Maven Nexus3 私服搭建与配置

Nexus3私服搭建、配置(Fu++聚合支付收款云平台

1、搭建 Nexus3 私服
①、首先下载安装 Nexus3,下载安装地址:https://www.sonatype.com/download-oss-sonatype ,以下是安装截图:
这里写图片描述
2、修改配置
打开bin/nexus.vmoptions文件,可修改相应配置,需修改服务器地址。

3、启动
配置完成后,cmd 打开远程客户端,进入nexus-3.0.1-01\bin下,nexus.exe /start nexus,启动成功后,访问:localhost:8081。默认的用户名和密码:admin/admin123,登录后看到如下图所示:这里写图片描述
4、项目中如何使用私服
mavensetting 文件中 settings 节点下找到 profiles 节点(无则创建),然后将下面代码加入其中:

方法一:

 <profile>  
   <!--profile的id-->
   <id>dev</id>  
    <repositories>
      <repository> 
                   <!--仓库id,repositories可以配置多个仓库,保证id不重复-->
        <id>nexus</id>  
                   <!--仓库地址,即nexus仓库组的地址-->
        <url>http:// 127.0.0.1:778/repository/maven-public/</url>  
                   <!--是否下载releases构件-->
        <releases>  
          <enabled>true</enabled>  
        </releases>  
                   <!--是否下载snapshots构件-->
        <snapshots>
          <enabled>true</enabled>
        </snapshots>  
      </repository>  
    </repositories> 
          <pluginRepositories> 
             <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
        <pluginRepository> 
                 <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
            <id>public</id> 
            <name>Public Repositories</name> 
            <url>http://127.0.0.1:778/repository/maven-public/</url> 
        </pluginRepository> 
    </pluginRepositories>

上面的 profile 标签需要激活,在 profiles 节点后面加入以下代码激活

<!--使用 **profile** 定义仓库需要激活才可生效-->
   <activeProfiles>
    <activeProfile>dev</activeProfile>
  </activeProfiles>

方法二:
在需要使用 maven 私服的 pom 文件中添加如下代码:

<repositories>
   <repository>
      <id>nexux</id>
      <name>maven-public</name>
   <url>http://127.0.0.1:778/repository/maven-public/</url>
   </repository>
</repositories>

猜你喜欢

转载自blog.csdn.net/fujaja/article/details/81623598
今日推荐