# Tag Archives: jersey

In previous post I discussed about Spring REST docs and I mentioned that I’m planning to give it a try. I was so enthusiastic when playing with Spring REST docs that I forgot that we are using Jersey. At first I was disappointed but then I started to look for a solution. The first hope come from Stack Overflow where I found that it is possible to use Spring Restdocs with Jersey application. I dug more and I updated my greeting service to use Jersey.

The first change was in pom.xml that was updated from:

to

I had to explicitly add org.springframework.restdocs:spring-restdocs-core with version 1.1.0.RELEASE because the transitive included one with version 1.0.1.RELEASE caused the following problems:

• org.springframework.restdocs.RestDocumentation does not implement org.springframework.restdocs.RestDocumentationContextProvider
• org.springframework.restdocs.restassured.RestAssuredRestDocumentation#documentationConfiguration() does not compile when an org.springframework.restdocs.RestDocumentation instance is sent as its parameter:

After I explicitly added org.springframework.restdocs:spring-restdocs-core with version 1.1.0.RELEASE I was able to compile.

Code was updated also like bellow.

changed to:

changed to:

changed to:

I had to use org.springframework.restdocs.JUnitRestDocumentation because org.springframework.restdocs.RestDocumentation is deprecated in org.springframework.restdocs:spring-restdocs-core with version 1.1.0.RELEASE.

changed to:

The only major change here was that include::{snippets}/greeting-controller-test changed to include::{snippets}/greeting-service-test because I renamed the test class.

and an empty applicationContext.xml in src/test/resources otherwise Jersey test fails:
After running mvn clean package generated documentation can be found in target/generated-docs folder: