找不到Gradle DSL方法:'compileOnly()'

Yog*_*Rai 1 intellij-idea gradle spring-boot

我正在尝试将新模块添加到我的应用程序中.我成功添加了movie-api模块(你可以在下面的图片中看到),但是当我尝试添加另一个模块(客户端应用程序)时,我收到错误,如图所示. 在此输入图像描述

我尝试了不同的解决方案,包括没有找到的Gradle DSL方法:'compile()',但是对我来说不起作用.感谢您的帮助!

Build.gradle文件:

buildscript {
    ext {
        springBootVersion = '1.4.3.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

jar {
    baseName = 'client-app'
    version = '0.0.1-SNAPSHOT'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter')
    compileOnly('org.projectlombok:lombok')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}
Run Code Online (Sandbox Code Playgroud)

Jam*_*tti 5

compileOnly在Gradle 2.12中引入.确保使用命令行和IDE的新版本.

  • 感谢您的回答,对不起我的回复.我正在使用Gradle 2.13并收到该错误. (4认同)