首页 > 编程知识 正文

maven配置本地镜像,maven删除没有下载成功的包

时间:2023-05-06 12:20:00 阅读:45136 作者:4542

maven配置阿里巴巴云镜像的两种方法配置方法第一种方法(settings.xml文件)在mirrors节点下加入一个新的mirror节点,配置阿里镜像地址,完整配置如下:

mirrorsmirroridalimaven/idnamealiyunmaven/name URL http://maven.a liyun.com/nexus/content/groups/public//URL mirrrry

有关此配置,请参阅https://gitee.com/renren io/renren-generator项目的pom.xml配置

repositoriesrepositoryidpublic/idnamealiyunnexus/name URL http://maven.a liyun.com/nexus/content/groups/public/rer repositoriespluginrepositoriespluginrepositoryidpublic/idnamealiyunnexus/name URL 3358 maven.a liyun.com/name URL 3358 urrrl releasessnapshotsenabledfalse/enabled/snapshot s/plugin存储库/插件存储库

第二种方法仅在当前项目中有效

解决的问题是在线最近公司布置了maven私服仓库,所以我们项目需要的依赖需要来自私服。 我的idea配置maven仓库的地址也是便服。 此外,如果是内部网开发,自己的笔记本电脑并不仅限于在公司使用。 自己学习切换maven仓库,相当麻烦

在示例测试中,创建一个新的springboot项目,定义本地没有的springboot版本,并在外部网上使用私服仓库地址进行打包

错误原因:由于我们使用的外网,不能拉着便服仓库依赖

解决方案适用于上述第二种方法(pom.xml方法)

在pom.xml上配置Alibaba云镜像

pom.xml配置如下:

? XML版本=' 1.0 '编码=' utf-8 '? project xmlns=' http://maven.Apache.org/POM/4.0.0 ' xmlns : xsi=' http://www.w3.org/2001/XML方案ins ttins maven-4.0.0.xsd ' model版本4.0.0/modelversiongroupidcom.exsd artifactidversion0.0.1- snapshot/versionion

gt;UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <spring-boot.version>2.2.5.RELEASE</spring-boot.version> </properties> <dependencies> 省略。。。 </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>${spring-boot.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>2.3.7.RELEASE</version> <configuration> <mainClass>com.example.springbootdemo.SpringbootDemoApplication</mainClass> </configuration> <executions> <execution> <id>repackage</id> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build><repositories><repository><id>public</id><name>aliyun nexus</name><url>http://maven.aliyun.com/nexus/content/groups/public/</url><releases><enabled>true</enabled></releases></repository></repositories><pluginRepositories><pluginRepository><id>public</id><name>aliyun nexus</name><url>http://maven.aliyun.com/nexus/content/groups/public/</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository></pluginRepositories></project>

打包过程:

打包结束

总结

1.如果工作电脑公司和自己两用,我们自己学习可以在pom.xml配置阿里云镜像,不过每个项目都要配置

2.如果电脑只是自己学习使用,我们在settings.xml中配置全局阿里云镜像即可,一劳永逸

个人csdn博客网址:https://blog.csdn.net/shaoming314

个人博客网址:www.shaoming.club

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。