gpt4 book ai didi

java - Gradle Spring Boot项目:从服务器接收到状态码501:必需HTTPS

转载 作者:行者123 更新时间:2023-12-03 03:10:29 29 4
gpt4 key购买 nike

我正在尝试使用gradle和groovy构建简单的hello world spring-boot项目。
当我运行“gradle clean build”时,出现以下错误。
到目前为止,我尝试过

  • 即使它是gradle项目,我还是将maven版本更新为Latest(3.6.3)。只是为了安全起见。
  • 我重新安装了intelliJ IDE
  • 我在build.gradle
  • 中将Maven网址添加为“https:”

    经过上述步骤后,我仍然低于错误。我不确定我还缺少什么。
    尽管我在gradle构建文件中提供了“https:” URL,但是我不确定从何处获取非安全的url(http)。
    Task :compileJava FAILED

    FAILURE: Build failed with an exception.

    * What went wrong:
    Execution failed for task ':compileJava'.
    > Could not resolve all dependencies for configuration ':detachedConfiguration1'.
    > Could not resolve org.springframework.boot:spring-boot-dependencies:2.1.1.RELEASE.
    Required by:
    project :
    > Could not resolve org.springframework.boot:spring-boot-dependencies:2.1.1.RELEASE.
    > Could not get resource 'http://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.1.1.RELEASE/spring-boot-dependencies-2.1.1.RELEASE.pom'.
    > Could not HEAD 'http://repo1.maven.org/maven2/org/springframework/boot/spring-boot-dependencies/2.1.1.RELEASE/spring-boot-dependencies-2.1.1.RELEASE.pom'. Received status code 501 from server: HTTPS Required

    我的gradle构建文件如下所示:
    plugins {
    id 'org.springframework.boot' version '2.3.1.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
    id 'war'
    }

    group = 'com.own.test'
    version = '0.0.1-SNAPSHOT'
    sourceCompatibility = '11'

    repositories {
    mavenLocal()
    maven {
    url = 'https://repo.maven.apache.org/maven2'
    }
    }



    dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
    exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    }

    test {
    useJUnitPlatform()
    }

    最佳答案

    使用start.spring.io,这是在那里生成的build.gradle的内容:

    plugins {
    id 'org.springframework.boot' version '2.3.1.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'groovy'
    }

    group = 'com.example'
    version = '0.0.1-SNAPSHOT'
    sourceCompatibility = '1.8'

    repositories {
    mavenCentral()
    }

    dependencies {
    implementation 'org.springframework.boot:spring-boot-starter'
    implementation 'org.codehaus.groovy:groovy'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
    exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    }

    test {
    useJUnitPlatform()
    }
    请注意主要区别:
  • groovy实际上作为插件和依赖项
  • 存在
  • Maven存储库是安全的。如错误消息所述,您已经使用
    https端点在这里
  • 关于java - Gradle Spring Boot项目:从服务器接收到状态码501:必需HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62852575/

    29 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com