在使用gradle构建项目时,用的私有Maven仓库地址是http协议的,会报这个错误
A problem occurred configuring root project 'erms'.
> Could not resolve all dependencies for configuration ':classpath'.
> Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://11.71.3.109:30000/repository/maven-public)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.6.4/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
在网上找了半天教程后说添加一个allowInsecureProtocol = true配置就可以,结果还是不行,会报allowInsecureProtocol 未知属性
Build file 'D:\Code\erms-master\build.gradle' line: 11
A problem occurred evaluating root project 'erms'.
> Could not find method allowInsecureProtocol() for arguments [true] on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
我的build.gradle文件是这样写的
buildscript {
repositories {
// mavenLocal()
maven { url 'http://ip::port/repository/maven-public'}
// allowInsecureProtocol true
gradlePluginPortal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "io.spring.gradle:dependency-management-plugin:1.1.0"
}
}
【解决方案】在上述配置依然报错后,可以将 allowInsecureProtocol true写在 url之后可以解决报错。。
repositories {
// mavenLocal()
maven { url 'http://ip::port/repository/maven-public'
allowInsecureProtocol true
}
//
gradlePluginPortal()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "io.spring.gradle:dependency-management-plugin:1.1.0"
}
}