[英]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,到目前为止,我尝试过,
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
实际上作为插件和依赖项存在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"
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.