刷新gradle项目时收到此错误:原因:类型代码无效:B3

时间:2019-08-11 17:26:52

标签: java gradle intellij-idea kotlin

点击“ 刷新所有gradle项目

我得到了错误:

  

原因:类型代码无效:B3

我试图刷新它,因为我添加了此依赖项:

implementation 'com.squareup.okhttp3:okhttp:3.0.1'

compile 'com.squareup.okhttp3:okhttp:3.0.1'

现在要在类中导入OkHttpClient,但是它不起作用

Java是12.0.1,Gradle是5.5

毕业代码:

settings.gradle文件:

    pluginManagement {
    repositories {
        mavenCentral()

        maven {
            url  "http://dl.bintray.com/mbuhot/maven"
        }
    }
    dependencies {
        compile 'mbuhot:eskotlin:0.7.0'
        compile group: 'com.mashape.unirest', name: 'unirest-java', version: '1.3.1'
        compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.4'


        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile 'com.android.support:appcompat-v7:23.0.0'
        compile 'com.google.android.gms:play-services:8.4.0'
        compile 'com.squareup.okhttp:okhttp:2.5.0'

    }
}
rootProject.name = 'ndmWebApp'

build.gradle文件:


    plugins {
    id 'org.springframework.boot' version '2.1.3.RELEASE'
    id 'org.jetbrains.kotlin.jvm' version '1.3.21'
    id 'org.jetbrains.kotlin.plugin.spring' version '1.3.21'
}

apply plugin: 'io.spring.dependency-management'

group = 'ProjectoFinal.ndmWebApp'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
    implementation 'org.jetbrains.kotlin:kotlin-reflect'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
    //elasticSearch
    implementation 'org.springframework.boot:spring-boot-starter-data-elasticsearch'

    implementation 'com.squareup.okhttp3:okhttp:3.0.1'

    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

compileKotlin {
    kotlinOptions {
        freeCompilerArgs = ['-Xjsr305=strict']
        jvmTarget = '1.8'
    }

1 个答案:

答案 0 :(得分:0)

这似乎是Java 11 +,Gradle 5和IntelliJ的open bug。 据我所知,您有两个选择:

  1. 将Gradle降级到5以下的版本。
  2. 使用命令行在IntelliJ之外构建项目。

here也提到了此错误。