How to modify dependency for Jersey projects built on Gradle?

社会主义新天地 提交于 2019-12-12 02:16:48

问题


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?


回答1:


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:

  • Jersey RESTful web service gradle setup

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




回答2:


Take the data that you add to your pom and add it like this top your build file...

dependencies {
    compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final'
}

You can copy the text of your pom file exactly.



来源:https://stackoverflow.com/questions/31817385/how-to-modify-dependency-for-jersey-projects-built-on-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!