首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么gradle不使用我指定的maven settings.xml?

为什么gradle不使用我指定的maven settings.xml?
EN

Stack Overflow用户
提问于 2022-02-17 12:54:26
回答 1查看 322关注 0票数 0

我的maven settings.xml如下所示。如您所见,这里没有http存储库url。所有存储库url都是用https启动的。

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
    <mirrors>
        <mirror>
            <id>mirror</id>
            <mirrorOf>central,jcenter,!rdc-releases,!rdc-snapshots</mirrorOf>
            <name>mirror</name>
            <url>https://maven.aliyun.com/nexus/content/groups/public</url>
        </mirror>

    </mirrors>
    <servers>
        <server>
            <id>rdc-releases</id>
            <username>myUserName</username>
            <password>myPwd</password>
        </server>
        <server>
            <id>rdc-snapshots</id>
            <username>myUserName</username>
            <password>myPwd</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <id>rdc</id>
            <properties>
                <altReleaseDeploymentRepository>
                    rdc-releases::default::https://packages.aliyun.com/maven/repository/2012878-release-sX3W6A/
                </altReleaseDeploymentRepository>
                <altSnapshotDeploymentRepository>
                    rdc-snapshots::default::https://packages.aliyun.com/maven/repository/2012878-snapshot-wXHWRP/
                </altSnapshotDeploymentRepository>
            </properties>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>https://maven.aliyun.com/nexus/content/groups/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
                <pluginRepository>
                    <id>snapshots</id>
                    <url>https://maven.aliyun.com/nexus/content/groups/public</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
                <pluginRepository>
                    <id>rdc-releases</id>
                    <url>https://packages.aliyun.com/maven/repository/2012878-release-sX3W6A/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
                <pluginRepository>
                    <id>rdc-snapshots</id>
                    <url>https://packages.aliyun.com/maven/repository/2012878-snapshot-wXHWRP/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>rdc</activeProfile>
    </activeProfiles>
</settings>

当我执行gradle构建时,它说我使用了不安全的协议。事实上,我从不在maven settings.xml中使用http协议。我们可以看到,所有的存储库url都是用'https://'‘启动的。有人能给我一些建议吗?

代码语言:javascript
运行
复制
## Exception is 
> Task :buildSrc:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildSrc:compileJava'.
> Could not resolve all dependencies for configuration ':buildSrc:compileClasspath'.
   > 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.4/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details. 

我的分级版本是7.4,build.gradle的一部分如下所示。这是一个多模块的项目。我以一个模块级设置为例。

settings.gradle

代码语言:javascript
运行
复制
/*
 * This file was generated by the Gradle 'init' task.
 */

rootProject.name = 'clougence-schema-parent'

include(':clougence-utils')

模块的build.gradle -utils

代码语言:javascript
运行
复制
/*
 * This file was generated by the Gradle 'init' task.
 */

plugins {
    id 'com.clougence.java-conventions'
}

description = 'clougence-utils'

groovy纸片

代码语言:javascript
运行
复制
/*
 * This file was generated by the Gradle 'init' task.
 */

plugins {
    id 'java-library'
    id 'maven-publish'
}

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    compileOnly 'org.slf4j:slf4j-api:1.7.30'
    compileOnly 'org.projectlombok:lombok:1.18.20'

    annotationProcessor 'org.projectlombok:lombok:1.18.20'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'

    testCompileOnly 'org.projectlombok:lombok:1.18.20'

    testImplementation 'com.alibaba:druid:1.2.6'
    testImplementation 'junit:junit:4.12'
    testImplementation 'net.hasor:hasor-db:4.3.0'
    testImplementation 'com.alibaba:druid:1.2.6'
}

group = 'com.clougence'
version = '1.0.12-SNAPSHOT'
java.sourceCompatibility = JavaVersion.VERSION_1_8

publishing {
    publications {
        maven(MavenPublication) {
            from(components.java)
        }
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-18 06:54:10

我自己找到答案。我曾经配置~/.gradle/init.gradle并设置HTTP,这迫使Gradle使用这个不安全的存储库

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71158529

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档