maven如何打包到自己的maven私服

1.首先你得有自己的maven

2.找到自己的maven的setting.xml文件
   
    配置方式如下
    <servers>
      <server>
            <id>maven-releases</id>
            <username>kunge</username>
            <password>kunge123</password>
       </server>
      <server>
            <id>maven-snapshots</id>
            <username>kunge</username>
            <password>kunge123</password>
      </server>
    </servers>
    这里配置的用户名和密码根据自己仓库设置的配置
3.这个修改好的之后idea会提示让你导入包,这个地方一定要导入包,否则在发布到maven的时候就会出现401的问题

    具体错误展示:
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project ons:
     Failed to deploy artifacts: Could not transfer artifact com.jiahui:ons:jar:1.0.0-20180613.031401-6 from/to maven-snapshots 
     (http://10.2.103.10:8081/repository/maven-snapshots/): 
     Failed to transfer file: http://192.168.52.130:8081/repository/maven-snapshots/com/jiahui/ons/1.0.0-SNAPSHOT/ons-1.0.0-20180613.031401-6.jar. 
     Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]

3.idea使用自己配置的maven的配置文件 

    eg:
    maven的文件目录
    D:/apache-maven-3.5.2 
    maven的setting.xml文件目录
    D:\apache-maven-3.5.2\conf\settings.xml

4.在项目的最外层配置打包到maven私服的pom内容
   
    具体配置如下:
      <repositories>
           <repository>
               <id>nexus</id>
               <name>local private nexus</name>
               <url>http://192.168.52.130:8081/repository/maven-public/</url>
               <releases>
                   <enabled>true</enabled>
               </releases>
               <snapshots>
                   <enabled>true</enabled>
               </snapshots>
           </repository>
       </repositories>
   
       <pluginRepositories>
           <pluginRepository>
               <id>nexus</id>
               <name>local private nexus</name>
               <url>http://192.168.52.130:8081/repository/maven-public/</url>
               <releases>
<enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> <distributionManagement> <repository> 这个id的名称要和server里面配置的id名称保持一致 <id>maven-releases</id> <name>Releases</name> 指定自己需要发布的maven私服 <url>http:// 192.168.52.130 :8081/repository/maven-releases/</url>
           </repository>
<snapshotRepository> 这个id的名称要和server里面配置的id名称保持一致 <id>maven-snapshots</id> <name>Snapshot</name> 指定自己需要发布的maven私服 <url>http://192.168.52.130:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement> 5.这些都配置好之后点开idea的maven的命令行,也就是Maven Projects打开自己模块的(我的模块也就是redis)-->Lifecycle-->deploy,点击deploy等待一会 成功的标志: [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.827 s [INFO] Finished at: 2018-06-13T11:02:20+08:00 [INFO] Final Memory: 25M/314M [INFO] ------------------------------------------------------------------------ 6.到自己的maven私服里面看看自己刚刚上传的jar eg: 打开maven私服仓库 [go](http://192.168.52.130:8081/#browse/browse) Browse | maven-snapshots(或者maven-releases) |--------com |--jiahui | redis--1.0-2018612.092029-1(jar所在的文件夹) | ons --1.0.0-20180613.030218-5(jar所在的文件夹) | oss --1.0.0-20180613.014829-5(jar所在的文件夹)
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值