我有一个 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 时,出现以下错误
无法解析我在 build.gradle 文件中提到的所有依赖项的配置所需的所有依赖项
。我想我已经正确地提到了存储库。我不明白为什么我的构建失败了。任何建议将不胜感激。
最佳答案
您需要将 repositories {...}
配置 block 添加到构建脚本中。在 buildscript {...}
block 中声明的内容仅用于解决构建脚本本身(在本例中为 javascript 插件)的依赖关系,但不用于解决项目依赖关系。
关于java - gradle项目构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27967211/