【发布时间】:2015-10-28 19:39:23
【问题描述】:
我想将 JSON 依赖项放在 build.gradle 中,以修复错误 MessageBodyWriter not found for media type=application/json。
在我的 previous question 中,我了解到我很可能没有在 build.gradle 文件中包含 JSON 作为依赖项。
我添加了如下所示的依赖(第8行,最后compile)
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 仍然给出相同的错误)。在我的球衣服务器端代码中,唯一与球衣相关的包是import org.glassfish.jersey.server.mvc.Viewable;
有人告诉我我需要添加什么吗?
【问题讨论】:
标签: java rest maven gradle jersey