解读maven配置阿里云镜像问题
maven配置阿里云镜像
打开maven配置文件,找到标签,添加如下:
<mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
设置全局的jdk,在配置文件配置如下:
<profile> <id>jdk18</id> <activation> <activeByDefault>true</activeByDefault> <jdk>1.8</jdk> </activation> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion> </properties> </profile>
设置局部的jdk,在项目的pom,xml文件中添加如下build元素
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.7</source> <target>1.7</target> </configuration> </plugin> </plugins> </build>
maven配置阿里云镜像仓库不生效
问题
在{MAVEN_HOME}/conf/settings.xml中添加镜像配置:
<mirrors> <mirror> <id>aliyunmaven</id> <mirrorOf>*</mirrorOf> <name>阿里云公共仓库</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> </mirrors>
但是项目更新时仍然会从http://repo.maven.apache.org/maven2下载依赖。
解决方法
在项目的pom.xml中添加如下配置
<repositories> <repository> <id>central</id> <url>https://maven.aliyun.com/repository/public</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>https://maven.aliyun.com/repository/public</url> </pluginRepository> </pluginRepositories>
原因
项目的pom会继承自super pom,在super pom中指定了从仓库的地址:
<repositories> <repository> <id>central</id> <name>Central Repository</name> <url>http://repo.maven.apache.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <name>Central Repository</name> <url>http://repo.maven.apache.org/maven2</url> <layout>default</layout> <snapshots> <enabled>false</enabled> </snapshots> <releases> <updatePolicy>never</updatePolicy> </releases> </pluginRepository> </pluginRepositories>
因此需要在项目中覆盖这一配置。
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
相关文章
SpringBoot整合Flyway的方法(数据库版本迁移工具)
这篇文章主要介绍了SpringBoot整合Flyway的方法(数据库版本迁移工具),本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2020-06-06
Java Stream map, Collectors(toMap, toLis
这篇文章主要介绍了Java Stream map, Collectors(toMap, toList, toSet, groupingBy, collectingAndThen)使用案例,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下2023-09-09
利用java、js或mysql计算高德地图中两坐标之间的距离
最近因为工作的需求,需要计算出高德地图中两个坐标的距离,通过查找相关资料发现了多种实现的方法,下面这篇文章主要给大家介绍了关于利用java、js或mysql计算高德地图中两坐标之间距离的相关资料,文中通过示例代码介绍的非常详细,需要的朋友可以参考下。2017-10-10
SpringBoot Webflux创建TCP/UDP server并使用handler解析数据
这篇文章主要介绍了SpringBoot Webflux创建TCP/UDP server并使用handler解析数据,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教2022-02-02


最新评论