java Gradle在Jersey/JAXRS项目中“无法解析配置的所有依赖项”
我想在构建中加入JSON依赖项。gradle,以修复错误MessageBodyWriter not found for media type=application/json
。
在我的previous question中,我了解到我很可能没有在构建中包含JSON作为依赖项。格雷德尔档案
我添加了如下所示的依赖项(第8行,lastcompile
)
apply plugin: 'war'
apply plugin: 'jetty'
dependencies {
compile fileTree(dir: 'lib', include: '**/*.jar')
compile(project(":qa-common"))
compile(project(":alm"))
compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.3.10'
}
jettyRun {
httpPort = 8080
reload = 'automatic'
scanIntervalSeconds = 2
daemon = false
}
现在我得到了Could not resolve all dependencies for configuration'
的错误
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':qa-automation-console:compile'.
> Cannot resolve external dependency org.glassfish.jersey.media:jersey-media-json-jackson:2.3.10 because no repositories are defined.
Required by:
qaauto:qa-automation-console:unspecified
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.273 secs
我正在检查是否包含了correct version of gradle和Jersey(在web.xml中,我看到了2.5,但2.5仍然给出了相同的错误)。在我的jersey服务器端代码中,与jersey相关的唯一包是import org.glassfish.jersey.server.mvc.Viewable;
有人告诉我需要补充什么吗
# 1 楼答案
在构建中定义存储库。格雷德尔喜欢跟随
或跟随
Gradle Help Chapter 8. Dependency Management Basics 8.5. Repositories给出了其他示例
您还应该根据现有的versions更改依赖项。由于您请求maven存储库中不存在的“Version2.3.10”,我链接了版本页