经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » Linux/Shell » 查看文章
Linux安装Nexus
来源:cnblogs  作者:废物大师兄  时间:2021/6/15 9:04:56  对本文有异议

当我们尝试从官网下载最新的Nexus 3.x的时候,哦吼,死活下载不下来

https://www.sonatype.com/products/repository-oss-download

https://sonatype-download.global.ssl.fastly.net/repository/downloads-prod-group/3/nexus-3.30.1-01-unix.tar.gz

https://help.sonatype.com/repomanager3/download/download-archives---repository-manager-3

于是,只得用docker安装Nexus

1.  安装Docker

首先找到Docker官方文档  https://docs.docker.com/get-docker/

按照文档一步步操作即可

https://docs.docker.com/engine/install/centos/ 

依次执行以下命令即可:

  1. yum install -y yum-utils
  2. yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  3. yum install docker-ce docker-ce-cli containerd.io

其它命令

  1. # Start Docker
  2. systemctl start docker
  3. systemctl stop docker
  4. systemctl status docker
  5. # Verify that Docker Engine is installed correctly
  6. docker run hello-world
  7. # Uninstall Docker Engine
  8. yum remove docker-ce docker-ce-cli containerd.io
  9. rm -rf /var/lib/docker
  10. rm -rf /var/lib/containerd

2.  安装nexus3

在docker hub上搜索nexus

https://hub.docker.com/

https://hub.docker.com/search?image_filter=official&type=image

  1. docker run -d -p 8081:8081 --name nexus sonatype/nexus3

手动指定nexus数据持久化目录

  1. docker volume create --name nexus-data
  2. docker run -d -p 8081:8081 --name nexus -v nexus-data:/nexus-data sonatype/nexus3

浏览器访问 http://ip:8081/

登录以后,我们修改admin的密码为admin123

接下来,我们创建两个仓库,一个代理阿里云的maven仓库,一个本地仓库

3.  配置maven仓库

首先,更改maven的settings.xml 

 

  1. 1 <?xml version="1.0" encoding="UTF-8"?>
  2. 2 <settings
  3. 3 xmlns="http://maven.apache.org/SETTINGS/1.2.0"
  4. 4 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. 5 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
  6. 6 <!-- localRepository
  7. 7 | The path to the local repository maven will use to store artifacts.
  8. 8 |
  9. 9 | Default: ${user.home}/.m2/repository
  10. 10 <localRepository>/path/to/local/repo</localRepository>
  11. 11 -->
  12. 12 <servers>
  13. 13 <server>
  14. 14 <id>releases</id>
  15. 15 <username>admin</username>
  16. 16 <password>admin123</password>
  17. 17 </server>
  18. 18 <server>
  19. 19 <id>snapshots</id>
  20. 20 <username>admin</username>
  21. 21 <password>admin123</password>
  22. 22 </server>
  23. 23 </servers>
  24. 24 <mirrors>
  25. 25 <mirror>
  26. 26 <id>nexus</id>
  27. 27 <name>nexus repository</name>
  28. 28 <url>http://192.168.28.31:8081/repository/maven-public/</url>
  29. 29 <mirrorOf>*</mirrorOf>
  30. 30 </mirror>
  31. 31 </mirrors>
  32. 32 <profiles>
  33. 33 <profile>
  34. 34 <id>jdk-1.8</id>
  35. 35 <activation>
  36. 36 <activeByDefault>true</activeByDefault>
  37. 37 <jdk>1.8</jdk>
  38. 38 </activation>
  39. 39 <properties>
  40. 40 <maven.compiler.source>1.8</maven.compiler.source>
  41. 41 <maven.compiler.target>1.8</maven.compiler.target>
  42. 42 <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
  43. 43 </properties>
  44. 44 </profile>
  45. 45 <profile>
  46. 46 <id>dev</id>
  47. 47 <repositories>
  48. 48 <repository>
  49. 49 <id>local-nexus</id>
  50. 50 <url>http://192.168.28.31:8081/repository/maven-public/</url>
  51. 51 <releases>
  52. 52 <enabled>true</enabled>
  53. 53 </releases>
  54. 54 <snapshots>
  55. 55 <enabled>true</enabled>
  56. 56 </snapshots>
  57. 57 </repository>
  58. 58 </repositories>
  59. 59 <pluginRepositories>
  60. 60 <pluginRepository>
  61. 61 <id>local-nexus</id>
  62. 62 <url>http://192.168.28.31:8081/repository/maven-public/</url>
  63. 63 <releases>
  64. 64 <enabled>true</enabled>
  65. 65 </releases>
  66. 66 <snapshots>
  67. 67 <enabled>true</enabled>
  68. 68 </snapshots>
  69. 69 </pluginRepository>
  70. 70 </pluginRepositories>
  71. 71 </profile>
  72. 72 </profiles>
  73. 73 <activeProfiles>
  74. 74 <activeProfile>dev</activeProfile>
  75. 75 <activeProfile>jdk-1.8</activeProfile>
  76. 76 </activeProfiles>
  77. 77 </settings>

项目的pom.xml文件中加上以下配置

  1. 1 <distributionManagement>
  2. 2 <repository>
  3. 3 <id>releases</id>
  4. 4 <url>http://192.168.28.31:8081/repository/maven-releases/</url>
  5. 5 </repository>
  6. 6 <snapshotRepository>
  7. 7 <id>snapshots</id>
  8. 8 <url>http://192.168.28.31:8081/repository/maven-snapshots/</url>
  9. 9 </snapshotRepository>
  10. 10 </distributionManagement>

然后就大功告成了

原文链接:http://www.cnblogs.com/cjsblog/p/14866335.html

 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号