What I want to do is to add Swagger to my REST Api based on Jersey 2.x.
But it seems Swagger for Jersey is based on Jersey 1.x. When I added the Swagger dependencies in Maven I get the following exception:
Exception in thread "main" java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:304)
at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:285)
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.<init>(GrizzlyHttpContainer.java:331)
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpServerFactory.createHttpServer(GrizzlyHttpServerFactory.java:119)
I think this is because
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jersey-jaxrs_2.10</artifactId>
<version>1.3.1</version>
</dependency>
has dependency to
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.13</version>
</dependency>
And this is in conflict to the Jersey 2.x my application is using. Is there a Swagger integration for Jersey 2.x available?
Any ideas how to solve my problem otherwise?
Use the following dependency instead:
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-jersey2-jaxrs_2.10</artifactId>
<version>1.3.10</version>
</dependency>
And that should solve your problem. We're going to release a new tutorial on how to integrate with jersey/jersey2 soon.