gradle7.5配置全局阿里云仓库

gradle7.5配置全局阿里云仓库

前言

最近安装了gradle7.5,但在配置的全局阿里云仓库的时候遇到不少问题,记录下。

配置过程

1.找到自己gradle主目录


例如:我这里是C:\Users\用户名\.gradle,当然网上好多教程说要在环境变量里面配置的gradle仓库目录下面也放一份,我这里试了下放不放都不影响,如果按照我这个没用可以试一下。

2、在主目录根路径下新建文件init.gradle,文件内容为:

allprojects{repositories {def REPOSITORY_URL = 'https://maven.aliyun.com/nexus/content/groups/public/'all { ArtifactRepository repo ->def url = repo.url.toString()if ((repo instanceof MavenArtifactRepository) && (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com'))) {project.logger.lifecycle 'Repository ${repo.url} replaced by $REPOSITORY_URL .'remove repo}}maven {url REPOSITORY_URL}}
}

遇到的错误

Could not resolve all dependencies for configuration ':detachedConfiguration5'.
Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/groups/public/)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.5/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details. 

把阿里云仓库地址http改成https就好了

本文链接:https://my.lmcjl.com/post/2339.html

展开阅读全文

4 评论

留下您的评论.