如何修改构建在Gradle上的Jersey项目的依赖关系? [英] How to modify dependency for Jersey projects built on Gradle?

查看:137
本文介绍了如何修改构建在Gradle上的Jersey项目的依赖关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图解决 MessageBodyWriter未找到在我创建的泽西岛项目中。我得到了很多修复依赖关系的建议,其中一些提到了更改pom.xml,但由于我得到的项目是在Gradle中构建和编译的,因此没有类似的xml。什么是类似的文件,我需要研究检查依赖关系?

解决方案


Maven&rarr ; Gradle == < groupId>:< artifactId>:< version>




所以

 < dependency> 
< groupId> org.glassfish.jersey.media< / groupId>
< artifactId> jersey-media-json-jackson< / artifactId>
< version> $ {jersey2.version}< / version>
< scope>运行时< / scope>
< /依赖关系>

在Gradle中是

  compile org.glassfish.jersey.media:jersey-media-json-jackson:${jersey2.version} 

$ {jersey2.version} 就是您正在使用的Jersey 2.x版本。



另请参阅: =https://stackoverflow.com/q/27889631/2587435>泽西REST风格的Web服务Gradle设置


注意:上述解决方案适用于您是否收到MessageBodyReader并且找不到application / json的情况。任何其他类型,那么你需要向我们展示堆栈跟踪。我只是说出最常见的一个(这就是你所链接的),因为你没有提供确切的堆栈跟踪消息。它确实可以用于任何类型,在这种情况下,这个答案是无关紧要的。您可能还会发现有用。只是关于MessageBodyReaders和MessageBodyWriters的一些一般信息

I was attempting to solve problems of MessageBodyWriter not found in a Jersey project I created. I got a lot of recommendations fixing the dependency, some of which mention changing pom.xml, but since the project I got was built and compiled in Gradle, there are not similar xml like that. What are the similar files I need to look into in terms of checking dependency?

解决方案

Maven → Gradle == <groupId>:<artifactId>:<version>

So

<dependency>
  <groupId>org.glassfish.jersey.media</groupId>
  <artifactId>jersey-media-json-jackson</artifactId>
  <version>${jersey2.version}</version>
  <scope>runtime</scope>
</dependency>

in Gradle would be

compile org.glassfish.jersey.media:jersey-media-json-jackson:${jersey2.version}

${jersey2.version} is whatever Jersey 2.x version you are using.

See Also:

Note: The above solution is for if you are getting a "MessageBodyReader nor found for application/json". Any other type, then you would need to show us the stacktrace. I am just stating the most common one (and that's what you have linked to), since you have not provided the exact stacktrace message. It could really be for any type, in which case this answer would be irrelevant. You might also find this useful. Just some general information about MessageBodyReaders and MessageBodyWriters

这篇关于如何修改构建在Gradle上的Jersey项目的依赖关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆