【发布时间】:2012-12-05 05:33:20
【问题描述】:
我想为许多项目重复使用某些过滤器,因此我想提取它并使用单个 jar 将其添加到任何 Web 应用程序中。
对于构建,我使用的是 Gradle 1.3 和以下 build.gradle 文件:
apply plugin: 'java'
dependencies {
compile group:'org.slf4j', name:'slf4j-api', version:'1.7.+'
testCompile group:'junit', name:'junit', version:'4.+'
compile group:'org.springframework', name:'spring-web', version:'3.+'
compile group:'org.slf4j', name:'slf4j-log4j12', version:'1.6.+'
compile group:'log4j', name:'log4j', version:'1.2.+'
providedCompile group: 'javax.servlet', name: 'javax.servlet-api', version:'3.+'
}
repositories {
mavenCentral()
}
如您所见,我需要 servlet api 才能成功编译此过滤器,所以我想像 maven 提供的依赖项一样添加它。
无论如何,在运行gradle build 后,我收到以下错误:
找不到参数的方法providedCompile() [{group=javax.servlet, name=javax.servlet-api, version=3.+}] 在根 项目“休眠对话上下文”。
现在,我知道我不能在没有 WAR 插件的情况下使用 providedCompile,但我需要项目是一个简单的 JAR。有没有其他方法可以做到这一点?
【问题讨论】:
标签: gradle