Nexus3.6安装、setting配置和jar包deploy

1.下载
 
    
  1. http://www.sonatype.com/download-oss-sonatype

2.安装/卸载(install\uninstall)【本文以Windows环境为例】
 
   
  1. cmd进入到解压目录:E:\nexus3.6\nexus-3.6.1-02-win64\nexus-3.6.1-02\bin
 
    
  1. E:\nexus3.6\nexus-3.6.1-02-win64\nexus-3.6.1-02\bin>nexus.exe /install
  2. Installed service 'nexus'.

3.启动服务
 
    
  1. cmd窗口:输入services.msc 找到nexus服务,点击启动

4.访问端口配置
 
    
  1. 进入E:\nexus3.6\nexus-3.6.1-02-win64\nexus-3.6.1-02\etc目录,打开nexus-default.properties文件
  2. ,找到application-port=9090,修改成你自己的端口
 
    
  1. ## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
  2. ##
  3. # Jetty section
  4. application-port=8081
  5. application-host=0.0.0.0
  6. nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
  7. nexus-context-path=/
  8. # Nexus section
  9. nexus-edition=nexus-pro-edition
  10. nexus-features=\
  11. nexus-pro-feature

5.启动/停止nexus
 
    
  1. cmd窗口 -> net start nexus(启动服务)
  2. net stop nexus(停止服务)

6.访问地址
 
    
  1. http://ip:端口/
 
     
  1. 默认账号密码:admin/admin123

7.访问地仓库类型
 
    
  1. hosted 宿主仓库:主要用于部署无法从公共仓库获取的构件(如 oracle  JDBC 驱动)以及自己或第三方的项目构件;
  2. proxy 代理仓库:代理公共的远程仓库;
  3. group 仓库组Nexus 通过仓库组的概念统一管理多个仓库,这样我们在项目中直接请求仓库组即可请求到仓库组管理的多个仓库。

Nexus3.6安装、setting配置和jar包deploy_第1张图片

8.配置私服(settings.xml
 
    
  1. xml version="1.0" encoding="UTF-8"?>
  2. <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  5. <localRepository>D:\Java\Maven\m2\repositorylocalRepository>
  6. <pluginGroups/>
  7. <proxies/>
  8. <servers>
  9. <server>
  10. <id>nexusid>
  11. <username>adminusername>
  12. <password>admin123password>
  13. server>
  14. <server>
  15. <id>newcapec-zhifu-releasesid>
  16. <username>adminusername>
  17. <password>admin123password>
  18. server>
  19. <server>
  20. <id>newcapec-zhifu-snapshotsid>
  21. <username>adminusername>
  22. <password>admin123password>
  23. server>
  24. servers>
  25. <mirrors>
  26. <mirror>
  27. <id>nexusid>
  28. <mirrorOf>*mirrorOf>
  29. <name>central repositoryname>
  30. <url>http://192.168.112.61:8081/repository/maven-public/
  31. mirror>
  32. mirrors>
  33. <profiles>
  34. <profile>
  35. <id>nexusid>
  36. <repositories>
  37. <repository>
  38. <id>nexusid>
  39. <name>Nexus Release Snapshot Repositoryname>
  40. <url>http://192.168.112.61:8081/repository/maven-releases/
  41. <releases>
  42. <enabled>trueenabled>
  43. releases>
  44. <snapshots>
  45. <enabled>trueenabled>
  46. snapshots>
  47. repository>
  48. repositories>
  49. <pluginRepositories>
  50. <pluginRepository>
  51. <id>nexusid>
  52. <name>Nexus Release Snapshot Repositoryname>
  53. <url>http://192.168.112.61:8081/repository/maven-releases/
  54. <releases>
  55. <enabled>trueenabled>
  56. releases>
  57. <snapshots>
  58. <enabled>trueenabled>
  59. snapshots>
  60. pluginRepository>
  61. pluginRepositories>
  62. profile>
  63. <profile>
  64. <id>jdk18id>
  65. <activation>
  66. <activeByDefault>trueactiveByDefault>
  67. <jdk>1.8jdk>
  68. activation>
  69. <properties>
  70. <maven.compiler.source>1.8maven.compiler.source>
  71. <maven.compiler.target>1.8maven.compiler.target>
  72. <maven.compiler.compilerVersion>1.8maven.compiler.compilerVersion>
  73. properties>
  74. profile>
  75. profiles>
  76. <activeProfiles>
  77. <activeProfile>nexusactiveProfile>
  78. activeProfiles>
  79. settings>

 
   
9.上传jar包到Nexus

  • pom方式:
 
    
  1. pom.xml中添加,和dependencies属于同一级别,在project级别下
 
    
  1. 
    <distributionManagement>
     <repository>
        <id>newcapec-zhifu-releasesid>
        <name>newcapec-zhifu-releasesname>
        <url>http://192.168.112.61:8081/repository/newcapec-zhifu-releases/url>
     repository>
     <snapshotRepository>
        <id>newcapec-zhifu-snapshotsid>
        <name>newcapec-zhifu-snapshotsname>
        <url>http://192.168.112.61:8081/repository/newcapec-zhifu-snapshots/url>
     snapshotRepository>
    distributionManagement>
 
     
  1. id为要上传的repository的唯一标示,url为要上传的repository的路径
 
    
  1. mvn deploy即可

  Nexus3.6安装、setting配置和jar包deploy_第2张图片
Nexus3.6安装、setting配置和jar包deploy_第3张图片
 
  • 命令方式:
 
    
  1. mvn deploy:deploy-file -DgroupId=xxx.xxx -DartifactId=xxx -Dversion=0.0.2 -Dpackaging=jar 
  2. -Dfile=D:\xxx.jar -Durl=http://xxx.xxx.xxx.xxx:8081/repository/3rdParty/ -DrepositoryId=3rdParty
 
    
  1. 其中-DgroupId 为上传的jargroupId
  2. -DartifactId 为上传的jarartifactId
  3. -Dversion 为上传的jar的需要被依赖的时候的版本号
  4. 然后是-Dpackagingjar,-Dfilejar包路径
  5. -Durl 为要上传的路径,可以通过以下方式获取到
  6. -DrepositoryId repository的唯一标示,跟第二步中赋权配置的server相同
参考来源:http://blog.csdn.net/iopfan/article/details/71107686

你可能感兴趣的:(nexus)