gradle项目的构建失败

时间:2015-01-15 15:41:28

标签: java gradle

我有一个java EE项目。我使用gradle作为构建工具。我的build.gradle文件如下所示:

apply plugin:'war'
apply plugin:'eclipse'

buildscript {
  repositories {   
   mavenCentral()   
   jcenter()
  }
  dependencies {
    classpath "com.eriwen:gradle-js-plugin:1.12.1"
  }
}

apply plugin: "com.eriwen.gradle.js"


minifyJs {
    source = file("src/main/webapp/js/App.js")
    dest = file("build/all-min.js")
    closure {
        warningLevel = 'QUIET'
    }
}

war.doFirst {
tasks.minifyJs.execute()
}

war.webInf {
from "build/all-min.js"
into "/js/"
}

dependencies{

    compile 'org.springframework:spring-context:4.1.4.RELEASE' 
    compile 'org.springframework:spring-core:4.1.4.RELEASE' 
    compile 'org.springframework:spring-web:4.1.4.RELEASE' 
    compile 'org.springframework:spring-webmvc:4.1.4.RELEASE'
    compile 'org.springframework:spring-jdbc:4.1.4.RELEASE'
    compile 'org.springframework:spring-tx:4.1.4.RELEASE'
    compile 'org.google.code.gson:gson:2.3.1+'
    compile 'log4j:log4j:1.2.17+'
    compile 'org.slf4j:jcl-over-slf4j:1.5.8+'
    compile 'org.slf4j:slf4j-api:1.5.8+'
    compile 'org.slf4j:slf4j-log4j12:1.5.8+'
    compile 'org.apache.commons:commons-dbcp2:2.0.1+'
    compile 'org.mybatis:mybatis-spring:1.2.2+'
    compile 'org.mybatis:mybatis:3.2.8+'
    compile 'com.oracle:ojdbc14:10.2.0.4.0+'
    compile 'commons-fileupload:commons-fileupload:1.2.1+'
    compile 'commons-io:commons-io:2.4+'
    compile 'junit:junit:4.11'
    compile 'javax.servlet:servlet-api:2.5'
}

但是当我尝试执行gradle build时,我收到以下错误

couldnot resolve all dependencies required for configuration表示我在build.gradle文件中提到的所有依赖项。我想我已经正确地提到了存储库。我无法弄清楚为什么我的构建失败了。任何建议都将不胜感激。

1 个答案:

答案 0 :(得分:1)

您需要在构建脚本中添加repositories {...}配置块。在buildscript {...}块中声明的那个仅用于解析构建脚本本身的依赖关系(在本例中为javascript插件),但它不用于解析项目依赖关系。