请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

初始化时报了以下错误是何原因呢

首先我的build.gradle.kts文件如下:

plugins {
    kotlin("jvm") version "1.8.0"
    application
}

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
    maven {
        url "https://maven.aliyun.com/repository/central"
    }
    mavenCentral()
}

dependencies {
    testImplementation(kotlin("test"))
}

tasks.test {
    useJUnitPlatform()
}

kotlin {
    jvmToolchain(8)
}

application {
    mainClass.set("MainKt")
}

我的gradle-wrapper.properties文件如下:

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

但是呢,我的报错信息如下:
图片描述
具体错误信息文本:

A problem occurred configuring root project 'HelloWorldGradle'.
> Could not resolve all files for configuration ':classpath'.
   > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0.
     Required by:
         project : > org.jetbrains.kotlin.jvm:org.jetbrains.kotlin.jvm.gradle.plugin:1.8.0
      > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0.
         > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.8.0/kotlin-gradle-plugin-1.8.0.pom'.
            > Could not GET 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.8.0/kotlin-gradle-plugin-1.8.0.pom'.
               > Connection reset

* 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.

点击上面的Load Script Configurations后重试,报另一个错误:

Caused by: org.gradle.internal.resolve.ModuleVersionResolveException: Could not resolve gradle:gradle:7.4.2.

正在回答 回答被采纳积分+3

1回答

bennyhuo 2023-03-21 08:28:19

        > Could not get resource 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.8.0/kotlin-gradle-plugin-1.8.0.pom'.            > Could not GET 'https://plugins.gradle.org/m2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.8.0/kotlin-gradle-plugin-1.8.0.pom'.               > Connection reset

这说明你下载 Kotlin Gradle 插件的时候下载失败了。看来你的网络存在一些问题啊。


在 settings.gradle.kts 里面配置一下仓库试试看:

pluginManagement {
    repositories {
        maven("https://mirrors.tencent.com/nexus/repository/maven-public")
        maven("https://mirrors.tencent.com/nexus/repository/gradle-plugins/")
        gradlePluginPortal()
    }
}


0 回复 有任何疑惑可以回复我~
  • 提问者 慕用0009290 #1
    又报了另一个错误啦
    ```
    Could not install Gradle distribution from 'https://services.gradle.org/distributions/gradle-7.4.2-bin.zip'.
    The cached zip file /Users/liyan/.gradle/wrapper/dists/gradle-7.4.2-bin/dgcfplbio1xt3j7nlr9pdbagu/gradle-7.4.2-bin.zip may be corrupted.
    ```
    回复 有任何疑惑可以回复我~ 2023-03-22 23:14:19
  • bennyhuo 回复 提问者 慕用0009290 #2
    同学,建议阅读一下错误信息哈。。。这是说你的本地文件损坏了。把本地的删了,重新下载。下不下来的话换我之前回复你的腾讯云的源。这些问题建议同学也先使用搜索引擎先自行解决一下,这对于学习编程是非常有帮助的。
    回复 有任何疑惑可以回复我~ 2023-03-22 23:21:04
  • 提问者 慕用0009290 回复 bennyhuo #3
    你说的这些都试过啦,把本地的删了重新下载也不行,或者是用你之前发我的腾讯云的源,都还是一样的错误
    回复 有任何疑惑可以回复我~ 2023-03-22 23:25:37
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信