简体   繁体   English

Gradle SpringBoot 项目:从服务器收到状态代码 501:HTTPS 必需

[英]Gradle SpringBoot Project : Received status code 501 from server: HTTPS Required

I am trying to build simple hello world spring-boot project with gradle and groovy.我正在尝试使用 gradle 和 groovy 构建简单的 hello world spring-boot 项目。
When I run 'gradle clean build', I am getting below error.当我运行“gradle clean build”时,我遇到了错误。

So far I tried,到目前为止,我尝试过,

  1. Even though it is a gradle project, I updated the maven version to latest(3.6.3).即使它是一个 gradle 项目,我也将 maven 版本更新为最新(3.6.3)。 Just to be a safer side.只是为了更安全的一面。
  2. I re-installed my intelliJ IDE我重新安装了我的 IntelliJ IDE
  3. I added maven url as "https:" in build.gradle我在 build.gradle 中将 maven url 添加为“https:”

After above steps, still I am getting below error.经过上述步骤,我仍然遇到错误。 I am not sure what else I am missing.我不确定我还缺少什么。 Though I have given 'https:' url in gradle build file, I am not sure from where it is taking the non-secure url(http).虽然我在 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

And my gradle build file looks:我的 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()
}

Using start.spring.io , this is the content of the build.gradle generated there:使用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()
}

Note the major differences:注意主要区别:

  • groovy is actually there as plugin and as dependency groovy实际上作为插件和依赖项存在
  • the maven repo is secure. maven 存储库是安全的。 As the error message states, you have use the https endpoint here如错误消息所述,您在此处使用了 https 端点

Finally, I figured out where to update the maven url to "https://*" for gradle projects.最后,我找到了将 gradle 项目的 maven url 更新为“https://*”的位置。

$ vi ~/.gradle/init.gradle

then I updated the maven url to secure protocol ("https://...")然后我将 maven url 更新为安全协议(“https://...”)

allprojects {
    repositories {
            mavenLocal()
            // Any Organization/Company specific repo url goes here
            maven {
                url "https://repo1.maven.org/maven2"
            }
    }
}


After above steps, it worked for me and able to build the spring-boot application successfully.经过上述步骤,它对我有用,并且能够成功构建 spring-boot 应用程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gradle build failed for Received status code 407 from server: Proxy Authentication Required, but another project's with similar deps Success - Gradle build fails for Received status code 407 from server: Proxy Authentication Required, but another project's with similar deps succeeds 从服务器收到状态代码 403:禁止禁用 Gradle“离线模式”并同步 ANDROID STUDIO 中的项目 - Received status code 403 from server: Forbidden Disable Gradle 'offline mode' and sync project in ANDROID STUDIO 无法在项目 XX 上执行目标无法解析项目的依赖关系。 返回码为: 501 , ReasonPhrase:HTTPS Required - Failed to execute goal on project XX Could not resolve dependencies for project. Return code is: 501 , ReasonPhrase:HTTPS Required 无法获取“https://google.bintray.com/.../maven-metadata.xml”。 从服务器收到状态代码 403:禁止访问 - Could not GET 'https://google.bintray.com/.../maven-metadata.xml'. Received status code 403 from server: Forbidden 无法获取“https://fyber.bintray.com/maven/com/fyber/fairbid-sdk/3.0.1/fairbid-sdk-3.0.1.aar”。 从服务器收到状态代码 403:禁止 - Could not GET 'https://fyber.bintray.com/maven/com/fyber/fairbid-sdk/3.0.1/fairbid-sdk-3.0.1.aar'. Received status code 403 from server: Forbidden Springboot Config 服务器客户端返回状态码:-1 - Springboot Config server client returns status code: -1 收到服务器响应,但无法访问状态代码 - Server responce received but status code can not be accessed AnySoftKeyboard:无法HEAD'play-publisher-2.0.0-beta1.pom'。 从服务器收到状态码401:未经授权 - AnySoftKeyboard : Could not HEAD 'play-publisher-2.0.0-beta1.pom'. Received status code 401 from server: Unauthorized Ubuntu 14.04 LTS上的Grails有奇怪的错误... /3.1.5/grails-dependencies-3.1.5.jar'。 从服务器收到状态码409:冲突 - Grails on Ubuntu 14.04 LTS with strange Error … /3.1.5/grails-dependencies-3.1.5.jar'. Received status code 409 from server: Conflict 在服务器上部署springboot项目时出现错误 - Deployment springboot project on server with error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM