下载安装
修改默认端口:
home\conf\nexus.properties
# Sonatype Nexus # ============== # This is the most basic configuration of Nexus. # Jetty section application-port=9080 application-host=0.0.0.0 nexus-webapp=${bundleBasedir}/nexus nexus-webapp-context-path=/nexus # Nexus section nexus-work=${bundleBasedir}/../sonatype-work/nexus runtime=${bundleBasedir}/nexus/WEB-INF
安装与启动
home\bin\nexus.bat
登录
http://localhost:9080/nexus
用户名、密码:admin/admin123
仓库说明
索引:
有些远程仓库拥有索引,下载其索引后,即使没有缓存远程仓库的jar包,我们也可以在本地搜索jar包的信息
手动更新索引
停止服务
删除 nexus-2.0.3-bundle\sonatype-work\nexus\indexer\central-ctx 下的索引
将下载索引包的所有内容复制到 nexus-2.0.3-bundle\sonatype-work\nexus\indexer\central-ctx ,重启服务且重新登陆
查看索引
搜索服务
设置镜像
<mirrors> <mirror> <id>mirrorId</id> <mirrorOf>*</mirrorOf> <name>Human Readable Name for this Mirror.</name> <url>http://localhost:9080/nexus/content/groups/public/</url> </mirror> </mirrors>当设置 mirrorOf 为 "*" 时,pom.xml中仓库是可以不用配置了
项目中加入新的依赖,将从私服中下载
<dependency> <groupId>com.demo.test</groupId> <artifactId>test-b</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency>
项目部署及远程仓库认证
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.demo.test</groupId> <artifactId>test-c</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>test-c</name> <url>http://maven.apache.org</url> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.10</version> <scope>test</scope> </dependency> <dependency> <groupId>com.demo.test</groupId> <artifactId>test-a</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>com.demo.test</groupId> <artifactId>test-d</artifactId> <version>0.0.1-SNAPSHOT</version> <exclusions> <exclusion> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>com.demo.test</groupId> <artifactId>test-b</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>abbot</groupId> <artifactId>abbot</artifactId> <version>0.12.3</version> </dependency> </dependencies> <!-- 部署 --> <distributionManagement> <!-- 发布版布置仓库 --> <repository> <id>test-c release</id> <name>Test-c Release</name> <url>http://localhost:9080/nexus/content/repositories/releases/</url> </repository> <!-- 快照版布置仓库 --> <snapshotRepository> <id>test-c snapshot</id> <name>Test-c Snapshot</name> <url>http://localhost:9080/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement> </project>
部署配置
<!-- 部署 --> <distributionManagement> <!-- 发布版布置仓库 --> <repository> <id>test-c release</id> <name>Test-c Release</name> <url>http://localhost:9080/nexus/content/repositories/releases/</url> </repository> <!-- 快照版布置仓库 --> <snapshotRepository> <id>test-c snapshot</id> <name>Test-c Snapshot</name> <url>http://localhost:9080/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>仓库认证
settings.xml
<servers> <server> <id>test-c release</id> <username>deployment</username> <password>deployment123</password> </server> <server> <id>test-c snapshot</id> <username>deployment</username> <password>deployment123</password> </server> </servers>运行命令
mvn clean deploy登录私服查看结果
快照版本:
项目构建之maven篇:5.仓库及nexus创建私服-2
时间: 2024-10-26 23:52:24