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.