kotlin + gradle + intellij - 没有定义存储库

kak*_*ote 7 intellij-idea gradle kotlin

任何人都可以帮助我吗?我只从前同事那里得到了项目源代码和 dockefile,没有解释工作,但我现在遇到了时间限制的麻烦。请请。


我在下面收到此错误消息

Could not determine the dependencies of task ':compileKotlin'.
Could not resolve all files for configuration ':kotlinCompilerClasspath'.
Cannot resolve external dependency org.jetbrains.kotlin:kotlin-compiler-embeddable:1.3.41 
because no repositories are defined.
Run Code Online (Sandbox Code Playgroud)

这是我的 build.gradle 下面

plugins {
    id 'idea'
    id "org.jetbrains.kotlin.jvm"  version "1.3.41"
    id "org.jetbrains.kotlin.kapt" version "1.3.41" apply false
    id "org.jetbrains.kotlin.plugin.spring" version "1.3.41" apply false
    id "org.jetbrains.kotlin.plugin.jpa"  version "1.3.41" apply false
    id "org.springframework.boot" version "2.1.6.RELEASE" apply false
    id "io.spring.dependency-management" version "1.0.7.RELEASE" apply false
    id "com.palantir.docker" version "0.22.1" apply false        
}
subprojects {
    group = "bawoori"
    version = "1.0"
    sourceCompatibility = 1.8
    apply plugin: "kotlin"
    apply plugin: "io.spring.dependency-management"

    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.41"
    }
    compileKotlin {
        kotlinOptions {
            freeCompilerArgs = ['-Xjsr305=strict']
            jvmTarget = '1.8'
        }
    }
    compileTestKotlin {
        kotlinOptions {
            freeCompilerArgs = ['-Xjsr305=strict']
            jvmTarget = '1.8'
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

小智 6

你需要添加allproject

plugins {
    id 'idea'
    id "org.jetbrains.kotlin.jvm"  version "1.3.41"
    id "org.jetbrains.kotlin.kapt" version "1.3.41" apply false
    id "org.jetbrains.kotlin.plugin.spring" version "1.3.41" apply false
    id "org.jetbrains.kotlin.plugin.jpa"  version "1.3.41" apply false
    id "org.springframework.boot" version "2.1.6.RELEASE" apply false
    id "io.spring.dependency-management" version "1.0.7.RELEASE" apply false
    id "com.palantir.docker" version "0.22.1" apply false
}

allprojects {
    group = "bawoori"
    version = "1.0"
    sourceCompatibility = "1.8"

    repositories {
        mavenCentral()
        jcenter()
    }

    compileKotlin {
        kotlinOptions {
            freeCompilerArgs = ['-Xjsr305=strict']
            jvmTarget = sourceCompatibility
        }
    }
    compileTestKotlin {
        kotlinOptions {
            freeCompilerArgs = ['-Xjsr305=strict']
            jvmTarget = sourceCompatibility
        }
    }
}
subprojects {
    apply plugin: "kotlin"
    apply plugin: "io.spring.dependency-management"

    repositories {
        mavenCentral()
        jcenter()
    }
}
Run Code Online (Sandbox Code Playgroud)


And*_*rey 5

您需要为构建脚本定义根 Gradle 项目的存储库:

buildscript {
    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.70"
    }
}

plugins {
    id "org.jetbrains.kotlin.<...>" version "1.3.70"
}

repositories {
    // this repo should be available in every subproject that uses kotlin
    mavenCentral() // or jcentrer
}
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅Kotlin 文档中的“使用 Gradle”部分。