“Nexus2:使用”的版本间差异

来自Wikioe
跳到导航 跳到搜索
 
(未显示同一用户的2个中间版本)
第2行: 第2行:


== 关于 ==
== 关于 ==
=== 浏览仓库 ===
参考: https://help.sonatype.com/repomanager2/using-the-user-interface/browsing-repositories


=== 管理仓库 ===
参考: https://help.sonatype.com/repomanager2/configuration/managing-repositories


== 初始使用 ==
== 初始使用 ==
第9行: 第13行:
如图:
如图:
: [[File:Nexus2:代理仓库“更新远程索引”.png|800px]]
: [[File:Nexus2:代理仓库“更新远程索引”.png|800px]]
: 如此,更新远程索引之后,才能确保代理仓库的状态可用。
* 其实就是在 '''Scheduled Tasks''' 增加了任务,用于更新该代理仓库的远程索引。


=== 宿主仓库:设置可重复部署 ===
=== 宿主仓库:设置可重复部署 ===
第178行: 第182行:
</settings>
</settings>
</syntaxhighlight>
</syntaxhighlight>
== 其他 ==
=== 离线更新索引 ===
参考: http://m.biancheng.net/nexus/offline-indexs.html

2021年12月20日 (一) 15:44的最新版本


关于

浏览仓库

参考: https://help.sonatype.com/repomanager2/using-the-user-interface/browsing-repositories

管理仓库

参考: https://help.sonatype.com/repomanager2/configuration/managing-repositories

初始使用

代理仓库:更新远程索引

如图:

Nexus2:代理仓库“更新远程索引”.png
  • 其实就是在 Scheduled Tasks 增加了任务,用于更新该代理仓库的远程索引。

宿主仓库:设置可重复部署

如图:

Nexus2:宿主仓库“可重复部署”.png

网络代理

有时候局域网是不能直接访问网络的,需要通过防火墙代理来上网,这个时候就需要在 Nexus 里配置代理来访问中央仓库和索引文件了。

如图:

Nexus2:网络代理设置.png

在 Maven 中使用 Nexus

项目配置

pom.xml 示例:(展开/隐藏)

...
	<repositories>
		<repository>
			<id>public</id>
			<url>http://localhost:8090/nexus/content/groups/public/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
	</repositories>
...
	<distributionManagement>
		<repository>
			<id>nexus2</id>
			<name>Nexus Release Repository</name>
			<url>http://localhost:8090/nexus/content/repositories/releases/</url>
		</repository>
		<snapshotRepository>
			<id>nexus2</id>
			<name>Nexus Snapshot Repository</name>
			<url>http://localhost:8090/nexus/content/repositories/snapshots/</url>
		</snapshotRepository>
	</distributionManagement>
...
  1. <repositories> 用于依赖下载;
  2. <distributionManagement> 用于部署上传;
    • <id> 必须与 setting.xml 中 <server> 下 <id> 一致

全局配置

settings.xml 示例:(展开/隐藏)

<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
	<!-- localRepository
	| The path to the local repository maven will use to store artifacts.
	|
	| Default: ${user.home}/.m2/repository
	<localRepository>/path/to/local/repo</localRepository>
	-->
	<localRepository>D:\Documents\Repository</localRepository>

	<!-- interactiveMode
	| This will determine whether maven prompts you when it needs input. If set to false,
	| maven will use a sensible default value, perhaps based on some other setting, for
	| the parameter in question.
	|
	| Default: true
	<interactiveMode>true</interactiveMode>
	-->

	<!-- offline
	| Determines whether maven should attempt to connect to the network when executing a build.
	| This will have an effect on artifact downloads, artifact deployment, and others.
	|
	| Default: false
	<offline>false</offline>
	-->

	<pluginGroups>
		<!-- pluginGroup
		 | Specifies a further group identifier to use for plugin lookup.
		<pluginGroup>com.your.plugins</pluginGroup>
		-->
	</pluginGroups>

	<proxies>
		<!-- proxy
		 | Specification for one proxy, to be used in connecting to the network.
		 |
		<proxy>
		  <id>optional</id>
		  <active>true</active>
		  <protocol>http</protocol>
		  <username>proxyuser</username>
		  <password>proxypass</password>
		  <host>proxy.host.net</host>
		  <port>80</port>
		  <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
		</proxy>
		-->
	</proxies>

	<servers>
		<server>
		  <id>nexus2</id>
		  <username>admin</username>
		  <password>@eijux</password>
		</server>

		<!-- Another sample, using keys to authenticate.
		<server>
		  <id>siteServer</id>
		  <privateKey>/path/to/private/key</privateKey>
		  <passphrase>optional; leave empty if not used.</passphrase>
		</server>
		-->
	</servers>

	<mirrors>
		<mirror>
			<id>nexus2</id>
			<name>nexus2</name>
			<mirrorOf>*</mirrorOf>
			<url>http://localhost:8090/nexus/content/groups/public/</url>
		</mirror>
	</mirrors>

	<profiles>
		<profile>
			<id>dev</id>
			
			<repositories>
				<repository>
					<id>public</id>
					<name>public</name>
					<url>http://localhost:8090/nexus/content/groups/public/</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</repository>
			</repositories>
			
			<pluginRepositories>
				<pluginRepository>
					<id>public</id>
					<name>public</name>
					<url>http://localhost:8090/nexus/content/groups/public/</url>
					<releases>
						<enabled>true</enabled>
					</releases>
					<snapshots>
						<enabled>true</enabled>
					</snapshots>
				</pluginRepository>
			</pluginRepositories>
		</profile>
	</profiles>

	<activeProfiles>
		<activeProfile>dev</activeProfile>
	</activeProfiles>
</settings>

其他

离线更新索引

参考: http://m.biancheng.net/nexus/offline-indexs.html