Maven私服Nexus3.x环境构建操作记录

参考链接:https://www.cnblogs.com/kevingrace/p/6201984.html

个人测试,我的pom.xml文件,里面添加了说明注释

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
<?xml version="1.0" encoding="UTF-8"?>
 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
 
  <groupId>com.zx</groupId>
  <artifactId>robot</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>jar</packaging>
  <!--<version>1.0.0-RELEASES</version> -->
 
  <name>robot Maven Webapp</name>
  <!-- FIXME change it to the project's website -->
  <url>http://www.example.com</url>
 
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <org.springframework.version>4.3.16.RELEASE</org.springframework.version>
  </properties>
 
  <dependencies>
    <dependency>
      <groupId>commons-codec</groupId>
      <artifactId>commons-codec</artifactId>
      <version>1.9</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>4.3.4.RELEASE</version>
      <scope>test</scope>
    </dependency>
    <!-- druid -->
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid</artifactId>
      <version>1.0.27</version>
    </dependency>
 
    <!-- spring framework start -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
 
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
 
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
 
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-orm</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
 
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jms</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
 
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-messaging</artifactId>
      <version>${org.springframework.version}</version>
    </dependency>
 
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-websocket</artifactId>
      <version>4.0.0.RELEASE</version>
    </dependency>
 
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.3.1</version>
    </dependency>
 
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>2.6.7</version>
    </dependency>
 
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.6.7</version>
    </dependency>
 
    <dependency>
      <groupId>org.codehaus.jackson</groupId>
      <artifactId>jackson-mapper-asl</artifactId>
      <version>1.8.8</version>
    </dependency>
    <!-- spring framework end -->
    <!-- MyBatis start -->
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.4.1</version>
    </dependency>
 
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis-spring</artifactId>
      <version>1.3.0</version>
    </dependency>
    <!-- MyBatis end -->
 
    <!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-websocket-api -->
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-websocket-api</artifactId>
      <version>7.0.65</version>
      <!-- 要加scope,否则,此依赖可能和tomcat自带的tomcat-websokcet.jar冲突,导致websocket链接建立不成功 -->
      <scope>provided</scope>
    </dependency>
 
 
    <!-- MySQL -->
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.37</version>
    </dependency>
    <!-- slf4j start -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.10</version>
    </dependency>
 
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-classic</artifactId>
      <version>1.1.2</version>
    </dependency>
 
    <dependency>
      <groupId>ch.qos.logback</groupId>
      <artifactId>logback-core</artifactId>
      <version>1.1.2</version>
    </dependency>
    <!-- slf4j end -->
 
    <!-- Jstl start -->
    <dependency>
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <!-- Jstl end -->
 
    <!-- Servlet start -->
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
    <!-- Servlet end -->
    <dependency>
      <groupId>javax.servlet.jsp</groupId>
      <artifactId>javax.servlet.jsp-api</artifactId>
      <version>2.3.1</version>
      <scope>provided</scope>
    </dependency>
 
    <dependency>
      <groupId>io.netty</groupId>
      <artifactId>netty-all</artifactId>
      <version>5.0.0.Alpha2</version>
    </dependency>
 
    <!-- aop start -->
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aspects</artifactId>
      <version>3.0.6.RELEASE</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjrt -->
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjrt</artifactId>
      <version>1.9.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
    <dependency>
      <groupId>org.aspectj</groupId>
      <artifactId>aspectjweaver</artifactId>
      <version>1.9.0</version>
    </dependency>
    <!-- aop end -->
 
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>2.6.7</version>
    </dependency>
 
    <dependency>
      <groupId>net.sf.json-lib</groupId>
      <artifactId>json-lib</artifactId>
      <version>2.4</version>
    </dependency>
 
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.5</version>
    </dependency>
 
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>dubbo</artifactId>
      <version>2.5.3</version>
      <exclusions>
        <exclusion>
          <artifactId>spring</artifactId>
          <groupId>org.springframework</groupId>
        </exclusion>
      </exclusions>
    </dependency>
 
    <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>4.5.5</version>
    </dependency>
 
    <!--  config redis data and client jar -->
    <dependency>
               <groupId>org.springframework.data</groupId>
               <artifactId>spring-data-redis</artifactId>
               <version>1.8.1.RELEASE</version>
    </dependency>
 
    <dependency>
               <groupId>redis.clients</groupId>
               <artifactId>jedis</artifactId>
               <version>2.9.0</version>
    </dependency>
 
  </dependencies>
 
 
  <repositories>
    <repository>
      <id>maven-public</id>
      <name>maven-public</name>
      <url>http://192.168.0.210:8081/repository/maven-public/</url>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>true</enabled>
      </releases>
    </repository>
  </repositories>
 
  <!--
      Snapshot包的管理
      1)修改Maven的settings.xml文件,加入认证机制
      <servers>
          <server>
              <id>nexus</id>
              <username>admin</username>
              <password>admin123</password>
         </server>
      </servers>
      2)修改工程的Pom文件,添加下方distributionManagement内容
        注意:snapshotRepository中的id的名字nexus要跟maven/conf/settings.xml文件中的名字一定要对应上
      3)上传到Nexus上
          1-项目编译成的jar是Snapshot(POM文件的头部)
            <groupId>com.woasis</groupId>
            <artifactId>test-nexus</artifactId>
            <version>1.0.0-<span style="color: #ff0000;">SHAPSHOT</span></version>
            <packaging>jar</packaging>
         2-使用mvn deploy命令运行即可(运行结果在此略过)
         3-因为Snapshot是快照版本,默认他每次会把Jar加一个时间戳,做为历史备份版本。
    -->
  <distributionManagement>
    <snapshotRepository>
      <id>nexus</id>
      <name>Nexus Snapshot</name>
      <url>http://192.168.0.210:8081/repository/maven-snapshots/</url>
      <uniqueVersion>false</uniqueVersion>
    </snapshotRepository>
    <site>
      <id>nexus</id>
      <name>Nexus Sites</name>
      <url>dav:http://192.168.0.210:8081/repository/maven-snapshots/</url>
    </site>
    <!--
          Releases包的管理
      1)与Snapshot大同小异,只是上传到私服上的Jar包不会自动带时间戳
      2)与Snapshot配置不同的地方,就是工程的PMO文件,额外加入repository配置
      3)打包的时候需要把Snapshot去掉,可以换成RELEASES
 -->
    <repository>
      <id>nexus</id>
      <name>Nexus Snapshot</name>
      <url>http://192.168.0.210:8081/repository/maven-releases/</url>
      <uniqueVersion>false</uniqueVersion>
    </repository>
  </distributionManagement>
 
 
  <build>
    <finalName>robot-1.0.0-SNAPSHOT</finalName>
 
    <resources>
    <!-- 这里的resource配置的是需要导入到项目的资源文件夹 -->
      <resource>
        <directory>src/main/resources</directory>
      </resource>
      <!-- 这里的${profiles.dir}是你上面配置的属性值,用于动态替换,比如打包的时候输入的是-Pdev则这里就是的${profiles.dir}就是dev的值 -->
      <resource>
        <directory>src/main/profile/${profiles.dir}</directory>
      </resource>
    </resources>
    <plugins>
      <!-- 编译install -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
      <!-- 打jar包 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <classesDirectory>target/classes/</classesDirectory>
          <archive>
            <manifest>
              <mainClass>com.alibaba.dubbo.container.Main</mainClass>
              <!-- 打包时 MANIFEST.MF文件不记录的时间戳版本,但是无法做到发布到nexus时,也不带时间戳 -->
              <useUniqueVersions>false</useUniqueVersions>
              <addClasspath>true</addClasspath>
              <classpathPrefix>lib/</classpathPrefix>
            </manifest>
            <manifestEntries>
              <Class-Path>.</Class-Path>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <!-- 开发环境 -->
      <id>dev</id>
      <properties>
        <!-- 这里的属性名是随便取的,可以在后续配置中引用 -->
        <profiles.dir>dev</profiles.dir>
      </properties>
      <!-- 是否默认 -->
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
    </profile>
    <profile>
      <!-- 线上环境 -->
      <id>pro</id>
      <properties>
        <!-- 这里的属性名是随便取的,可以在后续配置中引用 -->
        <profiles.dir>pro</profiles.dir>
      </properties>
    </profile>
    <profile>
      <!-- 本地环境 -->
      <id>local</id>
      <properties>
        <!-- 这里的属性名是随便取的,可以在后续配置中引用 -->
        <profiles.dir>local</profiles.dir>
      </properties>
    </profile>
  </profiles>
</project>

  

 

posted @   金鱼的第七秒记忆  阅读(487)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
点击右上角即可分享
微信分享提示