2016-12-20 104 views
0

我试图将新模块添加到我的应用程序中。我成功添加了movie-api模块(您可以在下面的图片中看到),但是当我尝试添加另一个模块(客户端应用程序)时,出现如图所示的错误。 enter image description here未找到Gradle DSL方法:'compileOnly()'

我试过不同的解决方案,包括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') 
} 
+0

显示你的build.gradle文件。听起来就像你没有应用java插件,或者有什么打破了解析。你可以通过命令行来建立吗?如果不是'build -s'任务输出是什么?另外检查:http://stackoverflow.com/questions/27617687/gradle-dsl-method-not-found-compile?noredirect=1&lq=1 – JBirdVegas

+0

@JBirdVegas,这是我的build.gradle –

+0

@JBirdVegas我已经添加了我的的build.gradle。你能看看它吗?谢谢:) –

回答

4

compileOnly在摇篮2.12中引入的。确保您使用的是足够新的版本,包括命令行和IDE。

+3

谢谢你的回答,并对我迟到的回应感到抱歉。我正在使用Gradle 2.13并获取该错误。 –

相关问题