您好,登录后才能下订单哦!
这篇文章给大家分享的是有关maven私服nexus怎么用的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。
1.修改maven全局配置文件 setting.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- | This is the configuration file for Maven. It can be specified at two levels: | | 1. User Level. This settings.xml file provides configuration for a single user, | and is normally provided in ${user.home}/.m2/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -s /path/to/user/settings.xml | | 2. Global Level. This settings.xml file provides configuration for all Maven | users on a machine (assuming they're all using the same Maven | installation). It's normally provided in | ${maven.conf}/settings.xml. | | NOTE: This location can be overridden with the CLI option: | | -gs /path/to/global/settings.xml | | The sections in this sample file are intended to give you a running start at | getting the most out of your Maven installation. Where appropriate, the default | values (values used when the setting is not specified) are provided. | |--> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <pluginGroups> <pluginGroup>org.apache.maven.plugins</pluginGroup> </pluginGroups> <!--链接仓库时用到的用户名 密码 通过id对应--> <servers> <server> <id>nexus-release</id> <username>admin</username> <password>1q</password> </server> <server> <id>nexus-snapshot</id> <username>admin</username> <password>1qa</password> </server> </servers> <profiles> <profile> <!-- 对应profile activeProfile字段--> <id>nexus</id> <!--依赖仓库--> <repositories> <repository> <id>nexus</id> <url>http://192.168.1.7:8081/repository/maven-public/</url> <releases> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </releases> <snapshots> <updatePolicy>always</updatePolicy> <enabled>true</enabled> </snapshots> </repository> </repositories> <!--插件仓库--> <pluginRepositories> <pluginRepository> <id>Aliyun</id> <name>Maven Aliyun Mirror</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile> </profiles> <!-- 激活profiles才能生效--> <activeProfiles> <!-- 对应profile中id字段--> <activeProfile>nexus</activeProfile> </activeProfiles> <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> <mirrors> <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | --> <!-- <mirror>--> <!-- <id>aliyun</id>--> <!-- <name>aliyun maven</name>--> <!-- <url>http://maven.aliyun.com/nexus/content/groups/public/</url>--> <!-- <mirrorOf>*</mirrorOf>--> <!-- </mirror>--> <!-- <mirror>--> <!-- <id>nexus</id>--> <!-- <url>http://192.168.1.7:8081/repository/maven-public/</url>--> <!-- <mirrorOf>*</mirrorOf>--> <!-- </mirror>--> </mirrors> </settings>
2.在项目中引用私服
<dependency> <groupId>com.iskytrip</groupId> <artifactId>iskytrip-framework-util</artifactId> <version>1.3</version> </dependency>
3.编译发布jar包
1).在项目pom.xml中配置私服地址
<distributionManagement> <repository> <id>nexus-release</id> <name>release</name> <url>http://192.168.1.7:8081/repository/maven-releases/</url> </repository> <snapshotRepository> <id>nexus-snapshot</id> <name>snapshot</name> <url>http://192.168.1.17:8081/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
2).在setting.xml中配置私服上传用户名和密码
<!--链接仓库时用到的用户名 密码 通过id对应--> <servers> <server> <id>nexus-release</id> <username>admin</username> <password>1qa</password> </server> <server> <id>nexus-snapshot</id> <username>admin</username> <password>1ol.</password> </server> </servers>
使用 mvn clean deploy 命令发布
说明:
release版本和snapshot版本区别
在pom.xml中配置<version>1.0-snapshot</version>即上传到snapshot库, 如配置<version>1.0</version>即上传release库
snapshot库中会根据时间自动生成版本后缀, 如: 1.0-20190826.073546-1 ,引用时也只需要<version>1.0-snapshot</version>即可引用最新snapshot库
不同maven库区别
maven-central -> maven中央公共库
maven-public -> 仓库组 可添加多个仓库, 项目只需引用组即可引用多个仓库
maven-release -> 发布库
maven-snapshot -> 测试库
感谢各位的阅读!关于“maven私服nexus怎么用”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。