找不到参数的方法compile()

lap*_*ots 18 gradle

我正在尝试执行一些.sql脚本,然后使用部署Web应用程序gradle tomcat plugin.

但是,当我尝试运行时,gradle我遇到了错误

在此输入图像描述

buildscript看起来像这样

buildscript {
//repository location
repositories {
    mavenCentral()
    jcenter()
}
//dependencies
//did not divide them into runtime&compile
dependencies {
    //aspectJ dependencies
    compile 'org.aspectj:aspectjlib:1.6.2'
    compile 'org.aspectj:aspectjrt:1.7.4'
    compile 'org.aspectj:aspectjweaver:1.7.4'
    //servlet
    compile 'javax.servlet:javax.servlet-api:3.0.1'
    //jdbc postresql
    compile 'org.postgresql:postgresql:9.2-1004-jdbc4'
    //commons dbcp
    compile 'commons-dbcp:commons-dbcp:1.2.2' 
    //spring & spring MVC dependencies
    compile 'org.springframework:spring-core:' + spring_version
    compile 'org.springframework:spring-web:' + spring_version
    compile 'org.springframework:spring-webmvc:' + spring_version
    compile 'org.springframework:spring-jdbc:' + spring_version
    compile 'org.springframework:spring-aspects:' + spring_version
    //spring security
    compile 'org.springframework.security:spring-security-core:' + spring_security_version
    compile 'org.springframework.security:spring-security-web:' + spring_security_version
    compile 'org.springframework.security:spring-security-config:' + spring_security_version
    //JSTL
    compile 'jstl:jstl:1.2'
    //slf4j-log4j
    compile 'org.slf4j:slf4j-api:1.7.0'
    compile 'org.slf4j:slf4j-log4j12:1.7.0'
    compile 'log4j:log4j:1.2.17'
    //mybatis
    compile 'org.mybatis:mybatis:3.2.4'
    compile 'org.mybatis:mybatis-spring:1.2.2'
    //gson
    compile 'com.google.code.gson:gson:2.2.4'
    //validation jsr303
    compile 'javax.validation:validation-api:1.0.0.GA'
    //junit4(test?)
    compile 'junit:junit:4.11'
    //spring test(test?)
    compile 'org.springframework:spring-test:' + spring_version
    //java mail
    compile 'javax.mail:mail:1.4'

    //tomcat plugin
    def tomcatVersion = '7.0.53'
    tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
        "org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
    tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
        exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
    }

    //additional classpath
    classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.3'
    classpath 'org.postgresql:postgresql:9.2-1004-jdbc4'
}
}
Run Code Online (Sandbox Code Playgroud)

build.gradle还有几个任务和几个apply plugin.

有什么问题?完整堆栈跟踪

在此输入图像描述

build.gradle在项目文件夹中.

Pet*_*ser 36

构建脚本混合了buildscript依赖项(即

  1. 构建本身的依赖关系; 通常这意味着Gradle插件
  2. 具有常规依赖性(即要编译/运行的代码的依赖性).

2需要进入dependencies { ... },而不是进入buildscript { dependencies { ... } }.

classpath依赖项之外的所有内容都是常规依赖项.