SpringBoot 快速下载最新的版本依赖(官方推荐)

序言:
SpringBoot 框架目前正处于高速迭代的过程,很多新版的依赖(如2.0.0.M6),我们可能无法及时从中央仓库进行下载。这里,官方提供了相应的仓库地址,我们可以在项目中进行设置。

指定远程仓库(含插件)

在当前工程的pom.xml 文件中指定Spring官方仓库的地址:

  • http://repo.spring.io/snapshot 快照版本,目前最新为2.0.0.x。
  • http://repo.spring.io/milestone 里程碑,适用于生产环境。
    
    
        
            spring-snapshots
            http://repo.spring.io/snapshot
            true
        
        
            spring-milestones
            http://repo.spring.io/milestone
        
    
    
    
        
            spring-snapshots
            http://repo.spring.io/snapshot
        
        
            spring-milestones
            http://repo.spring.io/milestone
        
    

其它小建议

1. 在本地镜像添加阿里云仓库

在本地的Maven 的 settings.xml 设置内容如下:





          
  D:\dev\repository

        
          
         
              alimaven
              central
             aliyun maven
             http://maven.aliyun.com/nexus/content/repositories/central/
          
     
      




2. 批量删除垃圾文件

遇到问题:
我们在使用Maven更新版本依赖的时候,经常因为网速的原因,未下载完成而导致产生垃圾文件(xxx.lastUpdated)。
解决办法:
将下面这段命名拷贝进去某个bat文件,然后执行,删除完毕。

@echo off
set REPOSITORY_PATH=D:\dev\mvnrepository (这里换成你的)
rem 开始删除... 
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
    del /s /q %%i
)
rem 删除完成!!
pause

你可能感兴趣的:(SpringBoot 快速下载最新的版本依赖(官方推荐))