此次搭建是在 Windows 平台上操作的,搭建之前需要先安装 JDK。
最新版是 nexus-3.2.0-01-win64.zip,可以从。
运行以下命令,注册为服务。
- nexus.exe /install Nexus Service
配置成功。
用户名: admin;
密码:admin123
没有 Maven 相关的 jar 包。
中添加以下配置
- C:\Users\Administrator\.m2\settings.xml
- <mirror>
- <id>
- nexus
- </id>
- <mirrorOf>
- central
- </mirrorOf>
- <url>
- http://localhost:8081/repository/maven-public/
- </url>
- </mirror>
在工程目录下,运行命令:
- mvn clean package
开始从私服下载 jar 包,快了很多。
私服中增加的 jar 包。
用 IntelliJ IDEA,远程部署 jar 到私服。
配置用户名和密码
- settings.xml
一定要是
下面的 settings.xml,IDEA 在 deploy 的时候会在这个路径下面查找远程私服的用户名和密码。
- C:\Users\用户名\.m2\settings.xml
- <server>
- <id>
- snapshots
- </id>
- <username>
- admin
- </username>
- <password>
- admin123
- </password>
- </server>
文件配置
- pom.xml
- <distributionManagement>
- <snapshotRepository>
- <id>
- snapshots
- </id>
- <url>
- http://localhost:8081/repository/maven-snapshots/
- </url>
- </snapshotRepository>
- </distributionManagement>
运行命令
- mvn clean -Dmaven.test.skip=true deploy
项目使用上传到私服的 jar,运行命令
- mvn clean package
更多命令可以参考。
来源: http://www.bubuko.com/infodetail-1947693.html