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

时间:2016-12-20 03:42:17

标签: intellij-idea gradle spring-boot

我正在尝试将新模块添加到我的应用程序中。我成功添加了movie-api模块(你可以在下面看到),但是当我尝试添加另一个模块(客户端应用程序)时,我收到错误,如图所示。 enter image description here

我尝试了不同的解决方案,包括Gradle DSL method not found: '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')
}

1 个答案:

答案 0 :(得分:5)

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