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>

以上文档有不对大家的请指正。

最新文章

  1. Sqlite 存储自定义对象
  2. Linux用户管理(centos)
  3. 测试dns
  4. 关于Hibernate5.x的那点事
  5. 移动APP的开发迭代离不开测试,你搞清楚其中的关键点了吗?
  6. 关于变量和函数前&amp;符号的作用
  7. Android修改Eclipse 中的Default debug keystore路径,以及修改android的AVD默认路径
  8. 数据结构 - 归并排序(merging sort)
  9. 【CodeForces】【148D】Bag of mice
  10. Spring transaction事务之roll back回滚
  11. C++常用容器
  12. Tradesy | IT桔子
  13. linux下使用scp远程传输自动输入密码
  14. liunx 系统调用 getopt() 函数
  15. 2734:十进制到八进制-poj
  16. Java框架之Hibernate(一)
  17. Linux Shell 命令--grep
  18. 学习HTML5 canvas遇到的问题
  19. python学习第一次笔记
  20. mapper代理方式开发

热门文章

  1. Python:Excel自动化实践入门篇 乙【送图书活动继续】
  2. Python爬虫:原来微博上的视频下载链接在这啊
  3. LeetCode-1601 最多可达成的换楼请求数目
  4. shell 命令小记
  5. AD域安装后无法打开网络适配器,提示无法访问指定设备,路径或文件,你可能没有。。。
  6. FTP调优
  7. 并发JUC
  8. drf内容总结
  9. 最火小游戏《羊了个羊》最新H5升级通关版
  10. netstate查找端口占用