“Nexus3:使用”的版本间差异
		
		
		
		
		
		跳到导航
		跳到搜索
		
				
		
		
	
 (建立内容为“category:Nexus   == 使用 ==  === 在 Maven 中使用 Nexus ===  === 在项目中使用 Nexus 查找依赖包 ===   === 部署编译完成的 jar 到 Nexus…”的新页面)  | 
				 (→使用)  | 
				||
| 第2行: | 第2行: | ||
=== 在 Maven 中使用 Nexus ===  | == 关于 ==  | ||
== 初始使用 ==  | |||
第一次使用 Nexus 3 需要进行一点配置,才能更好地使用它:  | |||
# 添加存储位置配置:  | |||
#: [[File:Nexus3:添加存储位置(Blob Stores).png|800px]]  | |||
# 添加仓库:  | |||
#: [[File:Nexus3:添加仓库(Repositories).png|800px]]  | |||
## 添加代理(proxy)仓库;  | |||
##*(应添加“Mavne - Publish Maven Indexer files”类型的任务,以更新其索引)  | |||
## 添加宿主(hosted)仓库;  | |||
##*(应设置其为“Allowed redeploy”)  | |||
## 添加仓库组(group);  | |||
##*(应为其添加不同的仓库成员才能使用,仓库成员必须注意顺序!)  | |||
=== '''代理仓库:添加任务更新远程索引''' ===  | |||
代理仓库状态:  | |||
: [[File:Nexus3:代理仓库状态.png|800px]]  | |||
# “Online - Remote Available”:可用;  | |||
# “Online - Ready to Connect”:不可用;  | |||
如图:  | |||
: [[File:Nexus3:添加任务:更新代理仓库的远程索引.png|800px]]  | |||
: 如此,更新远程索引之后,才能确保代理仓库的状态可用。  | |||
=== 宿主仓库:设置可重复上传===  | |||
如图:  | |||
:   | |||
=== 仓库组:添加仓库成员===  | |||
如图:  | |||
:   | |||
== 其他 ==  | |||
=== '''在 Maven 中使用 Nexus''' ===  | |||
# Maven 配置文件示例:  | |||
#: <syntaxhighlight lang="xml" highlight="">  | |||
<?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>maven-public</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>nexus3</id>  | |||
			<name>nexus3</name>  | |||
			<mirrorOf>*</mirrorOf>  | |||
			<url>http://localhost:8080/repository/maven-public/</url>  | |||
		</mirror>  | |||
	</mirrors>  | |||
	<profiles>  | |||
		<profile>  | |||
			<id>dev</id>  | |||
			<repositories>  | |||
				<repository>  | |||
					<id>maven-public</id>  | |||
					<name>maven-public</name>  | |||
					<url>http://localhost:8080/repository/maven-public/</url>  | |||
					<releases>  | |||
						<enabled>true</enabled>  | |||
					</releases>  | |||
					<snapshots>  | |||
						<enabled>true</enabled>  | |||
					</snapshots>  | |||
				</repository>  | |||
			</repositories>  | |||
			<pluginRepositories>  | |||
				<pluginRepository>  | |||
					<id>maven-public</id>  | |||
					<name>maven-public</name>  | |||
					<url>http://localhost:8080/repository/maven-public/</url>  | |||
					<releases>  | |||
						<enabled>true</enabled>  | |||
					</releases>  | |||
					<snapshots>  | |||
						<enabled>true</enabled>  | |||
					</snapshots>  | |||
				</pluginRepository>  | |||
			</pluginRepositories>  | |||
		</profile>  | |||
	</profiles>  | |||
	<activeProfiles>  | |||
		<activeProfile>dev</activeProfile>  | |||
	</activeProfiles>  | |||
</settings>  | |||
</syntaxhighlight>  | |||
# 在 IDEA 中更新 Maven 仓库索引:(先确保 Nexus 3 的仓库状态为“Online - Remote Available”)  | |||
#: [[File:IDEA:更新maven仓库索引.png|800px]]  | |||
=== 在项目中使用 Nexus 查找依赖包 ===  | === 在项目中使用 Nexus 查找依赖包 ===  | ||
2021年12月19日 (日) 20:11的版本
关于
初始使用
第一次使用 Nexus 3 需要进行一点配置,才能更好地使用它:
- 添加存储位置配置:
 - 添加仓库:
- 添加代理(proxy)仓库;
- (应添加“Mavne - Publish Maven Indexer files”类型的任务,以更新其索引)
 
 - 添加宿主(hosted)仓库;
- (应设置其为“Allowed redeploy”)
 
 - 添加仓库组(group);
- (应为其添加不同的仓库成员才能使用,仓库成员必须注意顺序!)
 
 
 - 添加代理(proxy)仓库;
 
代理仓库:添加任务更新远程索引
代理仓库状态:
- “Online - Remote Available”:可用;
 - “Online - Ready to Connect”:不可用;
 
如图:
宿主仓库:设置可重复上传
如图:
仓库组:添加仓库成员
如图:
其他
在 Maven 中使用 Nexus
- Maven 配置文件示例:
<?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>maven-public</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>nexus3</id> <name>nexus3</name> <mirrorOf>*</mirrorOf> <url>http://localhost:8080/repository/maven-public/</url> </mirror> </mirrors> <profiles> <profile> <id>dev</id> <repositories> <repository> <id>maven-public</id> <name>maven-public</name> <url>http://localhost:8080/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>maven-public</id> <name>maven-public</name> <url>http://localhost:8080/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <activeProfiles> <activeProfile>dev</activeProfile> </activeProfiles> </settings>
 - 在 IDEA 中更新 Maven 仓库索引:(先确保 Nexus 3 的仓库状态为“Online - Remote Available”)