找不到模块中参数的方法compile()

时间:2018-03-27 12:34:13

标签: java spring spring-boot gradle

我的项目结构如下https://zapodaj.net/d96c686a2cabe.png.html。有4个build.gradle个文件。一个通常在项目中,一个用于每个模块。 main build.gradle文件看起来像这个REST-Web-Service -> build.gradle

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

def javaProjects = subprojects.findAll {
    it.name == "common" & it.name == "core" && it.name == "web"
}

allprojects {
    apply plugin: 'idea'
    apply plugin: 'eclipse'

    repositories {
        jcenter()
    }
}

idea {
    project {
        jdkName = "1.8"
        languageLevel = "1.8"
        vcs = "Git"
    }
}

configure(javaProjects) {
    apply plugin: 'java'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    dependencies {
        ...
    }
}

但是,build.gradle模块中的common文件看起来像REST-Web-Service -> common -> build.gradle

group = 'com.common'


dependencies {

    compile("com.fasterxml.jackson.core:jackson-databind")
    compile("org.hibernate:hibernate-validator")
    compile("com.google.guava:guava")
    compile group: 'commons-validator', name: 'commons-validator', version: '1.6'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.6'
    compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.8.0'
    compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.8.0'
}

使用Gradle工具构建项目时,出现错误

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\Jonatan\Documents\GitHub\REST-Web-Services\common\build.gradle' line: 6

* What went wrong:
A problem occurred evaluating project ':common'.
> Could not find method api() for arguments [com.fasterxml.jackson.core:jackson-databind] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
Could not find method api() for arguments [com.fasterxml.jackson.core:jackson-databind] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

0 个答案:

没有答案