maven私服设置与使用详细
1.私服搭建环境
在Linux系统中,我选择比较方便下载安装docker容器,具体安装步骤可以根据Docker菜鸟教程安装自己需要的镜像。在这里我们先选择
Docker 安装 Nginx。这里就不做具体步骤讲解。
2.私服设置
私服搭建完成,我们输入默认用户名/密码:admin/admin123进入首页选择设置

在设置里面选择Repositories 创建自己本地仓库,在本例中我创建了两个自己的仓库wessence-releases和wessence-snapshots,并创建了一个分组wessence-public方便后续管理。
对应我创建的仓库,在这里对仓库类型做下简要说明:
hosted,本地仓库,通常我们会部署自己的构件到这一类型的仓库。比如公司的第二方库。
proxy,代理仓库,它们被用来代理远程的公共仓库,如maven中央仓库。
group,仓库组,用来合并多个hosted/proxy仓库,当你的项目希望在多个repository使用资源时就不需要多次引用了,只需要引用一个group即可。
对于仓库的创建,wessence-releases和wessence-snapshots创建方式一样,我们以wessence-releases为例



创建仓库分组,选择maven2(group)类型进行创建。

私服基础设置都这里设置完成,下面我们设置一下使用的settings和pom参数。下面是settings设置
1 <?xml version="1.0" encoding="UTF-8" ?>
2
3 <!--
4 Licensed to the Apache Software Foundation (ASF) under one
5 or more contributor license agreements. See the NOTICE file
6 distributed with this work for additional information
7 regarding copyright ownership. The ASF licenses this file
8 to you under the Apache License, Version 2.0 (the
9 "License"); you may not use this file except in compliance
10 with the License. You may obtain a copy of the License at
11
12 http://www.apache.org/licenses/LICENSE-2.0
13
14 Unless required by applicable law or agreed to in writing,
15 software distributed under the License is distributed on an
16 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 KIND, either express or implied. See the License for the
18 specific language governing permissions and limitations
19 under the License.
20 -->
21
22 <!--
23 | This is the configuration file for Maven. It can be specified at two levels:
24 |
25 | 1. User Level. This settings.xml file provides configuration for a single user,
26 | and is normally provided in ${user.home}/.m2/settings.xml.
27 |
28 | NOTE: This location can be overridden with the CLI option:
29 |
30 | -s /path/to/user/settings.xml
31 |
32 | 2. Global Level. This settings.xml file provides configuration for all Maven
33 | users on a machine (assuming they're all using the same Maven
34 | installation). It's normally provided in
35 | ${maven.home}/conf/settings.xml.
36 |
37 | NOTE: This location can be overridden with the CLI option:
38 |
39 | -gs /path/to/global/settings.xml
40 |
41 | The sections in this sample file are intended to give you a running start at
42 | getting the most out of your Maven installation. Where appropriate, the default
43 | values (values used when the setting is not specified) are provided.
44 |
45 |-->
46 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
47 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
48 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
49 <!-- localRepository
50 | The path to the local repository maven will use to store artifacts.
51 |
52 | Default: ${user.home}/.m2/repository
53 <localRepository>/path/to/local/repo</localRepository>
54 -->
55 <!--自定义本地仓库路径-->
56 <localRepository>D:\dev\localwar\local</localRepository>
57 <!-- interactiveMode
58 | This will determine whether maven prompts you when it needs input. If set to false,
59 | maven will use a sensible default value, perhaps based on some other setting, for
60 | the parameter in question.
61 |
62 | Default: true
63 <interactiveMode>true</interactiveMode>
64 -->
65
66 <!-- offline
67 | Determines whether maven should attempt to connect to the network when executing a build.
68 | This will have an effect on artifact downloads, artifact deployment, and others.
69 |
70 | Default: false
71 <offline>false</offline>
72 -->
73
74 <!-- pluginGroups
75 | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
76 | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
77 | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
78 |-->
79 <pluginGroups>
80 <!-- pluginGroup
81 | Specifies a further group identifier to use for plugin lookup.
82 <pluginGroup>com.your.plugins</pluginGroup>
83 -->
84 </pluginGroups>
85
86 <!-- proxies
87 | This is a list of proxies which can be used on this machine to connect to the network.
88 | Unless otherwise specified (by system property or command-line switch), the first proxy
89 | specification in this list marked as active will be used.
90 |-->
91 <proxies>
92 <!-- proxy
93 | Specification for one proxy, to be used in connecting to the network.
94 |
95 <proxy>
96 <id>optional</id>
97 <active>true</active>
98 <protocol>http</protocol>
99 <username>proxyuser</username>
100 <password>proxypass</password>
101 <host>proxy.host.net</host>
102 <port>80</port>
103 <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
104 </proxy>
105 -->
106 </proxies>
107
108 <!-- servers
109 | This is a list of authentication profiles, keyed by the server-id used within the system.
110 | Authentication profiles can be used whenever maven must make a connection to a remote server.
111 |-->
112 <servers>
113 <!-- server
114 | Specifies the authentication information to use when connecting to a particular server, identified by
115 | a unique name within the system (referred to by the 'id' attribute below).
116 |
117 | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
118 | used together.
119 |
120 -->
121 <server>
122 <!--id 自己设置,但是必须与pom文件中引入仓库的id一直,username,与password 是登录私服的用户名密码-->
123 <id>releases</id>
124 <username>admin</username>
125 <password>admin123</password>
126 </server>
127
128 <server>
129 <id>snapshots</id>
130 <username>admin</username>
131 <password>admin123</password>
132 </server>
133
134
135
136 <!-- Another sample, using keys to authenticate.
137 <server>
138 <id>release</id>
139 <privateKey>/path/to/private/key</privateKey>
140 <passphrase>optional; leave empty if not used.</passphrase>
141 </server>
142 -->
143 </servers>
144
145 <!-- mirrors
146 | This is a list of mirrors to be used in downloading artifacts from remote repositories.
147 |
148 | It works like this: a POM may declare a repository to use in resolving certain artifacts.
149 | However, this repository may have problems with heavy traffic at times, so people have mirrored
150 | it to several places.
151 |
152 | That repository definition will have a unique id, so we can create a mirror reference for that
153 | repository, to be used as an alternate download site. The mirror site will be the preferred
154 | server for that repository.
155 |-->
156 <mirrors>
157 <!-- mirror
158 | Specifies a repository mirror site to use instead of a given repository. The repository that
159 | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
160 | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
161 |
162 <mirror>
163 <id>mirrorId</id>
164 <mirrorOf>repositoryId</mirrorOf>
165 <name>Human Readable Name for this Mirror.</name>
166 <url>http://my.repository.com/repo/path</url>
167 </mirror>
168 -->
169 </mirrors>
170
171 <!-- profiles
172 | This is a list of profiles which can be activated in a variety of ways, and which can modify
173 | the build process. Profiles provided in the settings.xml are intended to provide local machine-
174 | specific paths and repository locations which allow the build to work in the local environment.
175 |
176 | For example, if you have an integration testing plugin - like cactus - that needs to know where
177 | your Tomcat instance is installed, you can provide a variable here such that the variable is
178 | dereferenced during the build process to configure the cactus plugin.
179 |
180 | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
181 | section of this document (settings.xml) - will be discussed later. Another way essentially
182 | relies on the detection of a system property, either matching a particular value for the property,
183 | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
184 | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
185 | Finally, the list of active profiles can be specified directly from the command line.
186 |
187 | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
188 | repositories, plugin repositories, and free-form properties to be used as configuration
189 | variables for plugins in the POM.
190 |
191 |-->
192 <profiles>
193 <!-- profile
194 | Specifies a set of introductions to the build process, to be activated using one or more of the
195 | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
196 | or the command line, profiles have to have an ID that is unique.
197 |
198 | An encouraged best practice for profile identification is to use a consistent naming convention
199 | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
200 | This will make it more intuitive to understand what the set of introduced profiles is attempting
201 | to accomplish, particularly when you only have a list of profile id's for debug.
202 |
203 | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
204 <profile>
205 <id>jdk-1.4</id>
206
207 <activation>
208 <jdk>1.4</jdk>
209 </activation>
210
211 <repositories>
212 <repository>
213 <id>jdk14</id>
214 <name>Repository for JDK 1.4 builds</name>
215 <url>http://www.myhost.com/maven/jdk14</url>
216 <layout>default</layout>
217 <snapshotPolicy>always</snapshotPolicy>
218 </repository>
219 </repositories>
220 </profile>
221 -->
222
223 <!--
224 | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
225 | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
226 | might hypothetically look like:
227 |
228 | ...
229 | <plugin>
230 | <groupId>org.myco.myplugins</groupId>
231 | <artifactId>myplugin</artifactId>
232 |
233 | <configuration>
234 | <tomcatLocation>${tomcatPath}</tomcatLocation>
235 | </configuration>
236 | </plugin>
237 | ...
238 |
239 | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
240 | anything, you could just leave off the <value/> inside the activation-property.
241 |
242
243 <profile>
244 <id>env-dev</id>
245
246 <activation>
247 <property>
248 <name>target-env</name>
249 <value>dev</value>
250 </property>
251 </activation>
252
253 </profile>
254 -->
255
256 <profile>
257 <!--激活仓库的唯一标识,自己设置名称 -->
258 <id>wessence_profile</id>
259 <repositories>
260 <!--包含需要连接到远程仓库的信息。id,name自己设置,不用和私服上的仓库名称致.在这个我们可以只设置我们的分组地址就可以了,具体引用到pom去设置 -->
261 <repository>
262 <!--远程仓库唯一标识 -->
263 <id>wessence-public</id>
264 <!--远程仓库名称 -->
265 <name>wessence-public</name>
266 <!--如何处理远程仓库里发布版本的下载 -->
267 <releases>
268 <!--true或者false表示该仓库是否为下载某种类型构件(发布版,快照版)开启。 -->
269 <enabled>true</enabled>
270 <!--该元素指定更新发生的频率。Maven会比较本地POM和远程POM的时间戳。这里的选项是:always(一直),daily(默认,每日),interval:X(这里X是以分钟为单位的时间间隔),或者never(从不)。 -->
271 <updatePolicy>never</updatePolicy>
272 <!--当Maven验证构件校验文件失败时该怎么做-ignore(忽略),fail(失败),或者warn(警告)。 -->
273 <checksumPolicy>warn</checksumPolicy>
274 </releases>
275 <!--如何处理远程仓库里快照版本的下载。有了releases和snapshots这两组配置,POM就可以在每个单独的仓库中,为每种类型的构件采取不同的策略。例如,可能有人会决定只为开发目的开启对快照版本下载的支持。参见repositories/repository/releases元素 -->
276 <snapshots>
277 <!--true或者false表示该仓库是否为下载某种类型构件(发布版,快照版)开启。 -->
278 <enabled>true</enabled>
279 <!--该元素指定更新发生的频率。Maven会比较本地POM和远程POM的时间戳。这里的选项是:always(一直),daily(默认,每日),interval:X(这里X是以分钟为单位的时间间隔),或者never(从不)。 -->
280 <updatePolicy>always</updatePolicy>
281 <!--当Maven验证构件校验文件失败时该怎么做-ignore(忽略),fail(失败),或者warn(警告)。 -->
282 <checksumPolicy>warn</checksumPolicy>
283 </snapshots>
284 <!--远程仓库URL,按protocol://hostname/path形式 -->
285 <url>http://自己ip或者域名:8081/repository/wessence-public/</url>
286 <!--用于定位和排序构件的仓库布局类型-可以是default(默认)或者legacy(遗留)。Maven 2为其仓库提供了一个默认的布局;然而,Maven 1.x有一种不同的布局。我们可以使用该元素指定布局是default(默认)还是legacy(遗留)。 -->
287 <layout>default</layout>
288 </repository>
289 </repositories>
290
291 <pluginRepositories>
292 <pluginRepository>
293 <id>wessence-group</id>
294 <name>Maven China Mirror</name>
295 <url>http://自己ip或者域名:8081/repository/wessence-public/</url>
296 <releases>
297 <enabled>true</enabled>
298 </releases>
299 <snapshots>
300 <enabled>true</enabled>
301 </snapshots>
302 </pluginRepository>
303 </pluginRepositories>
304
305 </profile>
306 </profiles>
307
308
309
310 <!-- activeProfiles
311 | List of profiles that are active for all builds.
312 -->
313 <activeProfiles>
314 <activeProfile>wessence_profile</activeProfile>
315 </activeProfiles>
316
317 </settings>
pom设置
<distributionManagement>
<repository>
<!--id 必须与settings里面的server id一致-->
<id>releases</id>
<name>corp nexus-releases</name>
<url>http://自己ip或者域名:8081/repository/wessence-releases/</url>
</repository>
<snapshotRepository>
<!--id 必须与settings里面的server id一致-->
<id>snapshots</id>
<name>corp nexus-snapshot</name>
<url>http://自己ip或者域名:8081/repository/wessence-snapshots/</url>
</snapshotRepository>
</distributionManagement>
以上文档有不对大家的请指正。
maven私服设置与使用详细的更多相关文章
- Maven私服(Repository Manager) - Nexus安装和使用(详细过程)
Maven私服的安装和使用. (注:原创文章,引用请注明来自Clement-Xu的博客!) Maven私服(即Repository Manager)的主要作用: 减少从远方仓库下载的次数,节省带宽.提 ...
- 【Maven】3.使用IntelliJ IDEA 使用本地搭建的maven私服,而不是使用默认的maven设置
安装Idea的教程:http://www.cnblogs.com/sxdcgaq8080/p/7641379.html 搭建maven私服的教程:http://www.cnblogs.com/sxdc ...
- Maven私服Nexus3.x环境构建操作记录
Maven介绍Apache Maven是一个创新的软件项目管理和综合工具.Maven提供了一个基于项目对象模型(POM)文件的新概念来管理项目的构建,可以从一个中心资料片管理项目构建,报告和文件.Ma ...
- Ubuntu server下搭建Maven私服Nexus
Ubuntu server下搭建Maven私服Nexus Maven私服Nexus的作用,主要是为了节省资源,在内部作为maven开发资源共享服务器来使用. 1.下载 通过root用户进去Ubuntu ...
- maven仓库总结,maven私服搭建
配置pom.xml依赖包时在这里找包的描述: http://search.maven.org/#browse 以java为根目录. mvn archtype:generate -DgroupId=zt ...
- centos7搭建nexus maven私服
前置条件: 1.安装jdk,可参考 http://www.cnblogs.com/grey-wolf/p/6480489.html 2.nexus仓库管理器,分为两个版本,Nexus Reposito ...
- Linux下Maven私服Nexus3.x环境构建操作记录【转】
Maven介绍Apache Maven是一个创新的软件项目管理和综合工具.Maven提供了一个基于项目对象模型(POM)文件的新概念来管理项目的构建,可以从一个中心资料片管理项目构建,报告和文件.Ma ...
- 【Maven】2.使用Nexus3搭建Maven私服+上传第三方jar包到本地maven仓库
参考文章: http://www.cnblogs.com/luotaoyeah/p/3791966.html --------------------------------------------- ...
- Centos7 搭建最新 Nexus3 Maven 私服
Maven 介绍 Apache Maven 是一个创新的软件项目管理和综合工具.Maven 提供了一个基于项目对象模型(POM)文件的新概念来管理项目的构建,可以从一个中心资料片管理项目构建,报告和文 ...
- 使用Nexus3搭建Maven私服
1.搭建Maven私服背景 公司还是按捺不住,要搭建一个自己的Maven本地仓库,可以让开发人员down架包,从内网还是快很多. 这样公司的maven本地仓库就是 开发人员自己电脑上的maven仓库 ...
随机推荐
- DBeaver连接clickhouse无法下载驱动的情况
最近遇到dbeaver 连接clickhouse的时候提示下载驱动失败. 在网上找了些方法也不行,其中包括默认下载.配置阿里云的Maven. 最后在网上找到一个驱动包,自己手动添加即可.把下载地址分享 ...
- Day 13 13.2 requests之请求参数与请求体
请求参数与请求体参数 一.什么是params参数(请求参数) get 方法是可以向服务器发送信息的,除了可以请求需要的页面之外,也可以发送我们指定的内容,这就是通过 params 参数实现的 requ ...
- netstate查找端口占用
netstat -nao 列出本机端口占用信息加上|findstr 筛选 各个字段的意思: 协议 本地地址:端口 外部地址:端口 状态 PID 这 ...
- Java实现简单薪水计算器相关操作代码
/** * 薪水计算器 * 1.通过键盘输入用户的月薪,每年是几个薪水 * 2.输出用户年薪 * 3.输出一行字"如果年薪超过10万,恭喜你超越了90%的国人:如果年薪超过了20万,恭喜你超 ...
- Aspose.Cells 拒绝访问、数据库 64 bit mode with the 32 bit Oracle、视图加载格式不正确。
第一次遇到发布程序后,引发的这么多奇葩问题.记录一下. 配置:windows server 2018 R2 企业版 sp1 这是一台闲置4年机子,拿到机子里面已经安装过oracle客户端,我直接卸载装 ...
- Datax-web入门配置与启动
在idea中启动Datax-web 需要先将Datax在本地安装,可以参考这篇文章(datax在win10中的安装) 1.从github上拉取源码 https://github.com/WeiYe-J ...
- PageHelper大致逻辑
简单涉及以下几个类: PageHelper PageMethod PageParam PageInterceptor implement Interceptor PageHelperAutoC ...
- Si24R2F+ 无线发射芯片的主要特性及应用介绍
Si24R2F+ 是一颗工作在 2.4GHz ISM 频段,专为低功耗无线场合设计,集成嵌入式发射基带的无线发射芯片.工作频率范围为 2400MHz-2525MHz,共有 126 个 1MHz 带宽的 ...
- SpringBoot + Shiro + Redis + JWT 实现无状态登录
这是一篇随笔和心得,不会写入任何的一种代码.只是提供一种逻辑. 在我之后,我会发现这种逻辑尤为重要 最近在做一套通用的权限管理项目,考虑使用的是Shiro 的这个框架.认证和鉴权就是权限框架所解决的问 ...
- react hook入门
useState的使用 代码 const Search = (props: any) => { // useState() 采用一个初始 state 作为参数,也可以像这样使用一个空字符串. / ...