首页 归档 关于 文件 Github
×

Maven项目的Pom配置

2020-09-24 15:37:39
Maven
  • pom
本文总阅读量(次):
本文字数统计(字):610
本文阅读时长(分):3

属性配置

1
2
3
4
5
6
7
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<!-- 过滤测试 -->
<skipTests>true</skipTests>
</properties>

依赖引入

1
2
3
4
5
6
7
8
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
</dependency>

</dependencies>

打包配置

1
2
3
4
5
6
<build>
<finalName>项目名称</finalName>
<plugins>
<!-- 插件 -->
</plugins>
</build>

插件

代理仓库配置

开启项目本身的代理仓库配置

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
<project>
<repositories>
<repository>
<id>spring</id>
<url>https://maven.aliyun.com/repository/spring</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring</id>
<url>https://maven.aliyun.com/repository/spring</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

</project>

但有时,跟着上面的设置方法并不奏效,仍然还是从之前的镜像站中去下载。
此时,我们需要去检查下 Maven 安装目录下的settings.xml:

1
2
3
4
5
6
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

可以看到,在设置镜像时,mirrorOf设置为了“*”,意味所有的依赖都是从这个镜像上下载。完全不给Spring Snapshots机会了。

解决方法也简单,改为下面的方式:

1
2
3
4
5
6
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>*,!spring-snapshots</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

mirrorOf设置为了“*,!spring-snapshots”,表示除了Spring Snapshots外,所有的依赖都将从这个镜像上下载。

mirrorOf的配置支持如下场景:

1
2
3
4
*:所有依赖;
external:*:所有不再本地和不是基于文件的依赖;
repo,repo1:所有来自repo或者repo1仓库的依赖;
*,!repo1:除了repo1外的所有依赖。即上面示例中的场景。
完
Jackson 的 使用
Maven项目的结构定义

本文标题:Maven项目的Pom配置

文章作者:十二

发布时间:2020-09-24 15:37:39

最后更新:2022-03-01 18:28:17

原始链接:https://www.zhuqiaolun.com/2020/09/1600933059831/1600933059831/

许可协议:署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

头像

十二

我想起那天夕阳下的奔跑,那是我逝去的青春。

分类

  • Blog4
  • ElasticSearch13
  • Freemarker2
  • Git2
  • Go-FastDfs2
  • IDEA2
  • J-Package6
  • J-Tools21
  • Java2
  • JavaFx3
  • Kafka4
  • Linux2
  • Logger5
  • Maven5
  • MyBatis6
  • MyCat3
  • MySql2
  • Nginx5
  • OceanBase1
  • RabbitMq4
  • Redis6
  • SVN1
  • SpringBoot11
  • Tomcat6
  • WebService2
  • Windows2
  • kubernetes10

归档

  • 二月 20251
  • 十二月 20244
  • 八月 202416
  • 六月 20241
  • 九月 20231
  • 八月 20231
  • 七月 20232
  • 八月 20222
  • 三月 202214
  • 二月 20224
  • 十一月 20211
  • 七月 20215
  • 六月 20213
  • 五月 20213
  • 四月 20211
  • 三月 202116
  • 二月 20212
  • 一月 20211
  • 十一月 202014
  • 十月 20201
  • 九月 202014
  • 八月 20205
  • 七月 20204
  • 六月 20208
  • 五月 20208

作品

我的微信 我的文件

网站信息

本站运行时间统计: 载入中...
本站文章字数统计:96.9k
本站文章数量统计:132
© 2025 十二  |  鄂ICP备18019781号-1  |  鄂公网安备42118202000044号
驱动于 Hexo  | 主题 antiquity  |  不蒜子告之 阁下是第个访客
首页 归档 关于 文件 Github