1445673355的gravatar头像
1445673355 2018-08-10 12:27:30
MAVEN私服搭建和使用

MVN私服搭建和使用

1.使用Nexus3搭建Maven私服

1.1下载安装Nexus3

nexus3的下载地址:https://www.sonatype.com/download-oss-sonatype 

 

MAVEN私服搭建和使用

1.2修改配置

打开bin/nexus.vmoptions文件,可修改相应配置。

需修改服务器地址

1.3启动

配置完成后,cmd打开远程客户端,进入nexus-3.0.1-01\bin下,nexus.exe /start nexus

启动成功后,访问:localhost:8081。

默认的用户名和密码:admin/admin123,登录后看到如下图所示

MAVEN私服搭建和使用

2.使用

2.1私服仓库配置

 

2.2私服如果添加第三方jar包

登录账户:admin/admin123

MAVEN私服搭建和使用

MAVEN私服搭建和使用

2.3项目中如何使用私服

1.方法一

在maven的setting文件中<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>

 

2.方法二

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

<repositories>

   <repository>

      <id>nexux</id>

      <name>maven-public</name>

   <url>http://127.0.0.1:778/repository/maven-public/</url>

   </repository>

</repositories>

 


打赏

已有1人打赏

最代码官方的gravatar头像
最近浏览
123123lol  LV1 2021年11月15日
demogeforce  LV2 2021年9月7日
liangkai123  LV1 2021年8月27日
liang20223141  LV1 2021年2月19日
冰枫xjz8  LV31 2020年11月20日
ym1997  LV1 2020年11月20日
yuanfen  LV16 2020年8月7日
hellogege  LV1 2020年7月29日
dongguangming 2020年5月19日
暂无贡献等级
756124136 2020年5月6日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友