kongchen / swagger-maven-plugin

JAX-RS & SpringMVC supported maven build plugin, helps you generate Swagger JSON and API document in build phase.
http://kongchen.github.io/swagger-maven-plugin/
Apache License 2.0
761 stars 451 forks source link

Update JAX-RS API JAR; mark as "provided". #543

Open garretwilson opened 7 years ago

garretwilson commented 7 years ago

I'm confused as to why jsr311-api is included as a required dependency. It it an old version of the spec --- version 1.x. The latest version is JAX-RS 2.x. Most people I would hope are using the latest version of the spec anyway.

Including the old one really hurts us --- it overrides some of the classes we have included specifically using the latest version, and we may not know it until we deploy an application using the annotations, and we get:

exception: java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;

See for example https://stackoverflow.com/q/19225618/421049 .

And can't you mark the JAX-RS dependency as provided? That way it won't be included at runtime --- and doesn't need to be included at runtime, because the classes get the JAX-RS API classes from the container. This would skip the whole problem altogether.

<dependency>
  <groupId>javax.ws.rs</groupId>
  <artifactId>javax.ws.rs-api</artifactId>
  <version>2.1</version>
  <scope>provided</scope>
</dependency>

This was just a huge pain on a large production system we're trying to deploy, just because we added some swagger-maven-plugin annotations.

garretwilson commented 7 years ago

Oh, OK, I see it is a little more complicated than this.

The javax.ws.rs:jsr311-api:1.1.1 dependency is getting pulled in, not directly, but via io.swagger:swagger-core:1.5.13, which comes in via io.swagger:swagger-jaxrs:1.5.13 which you use.

I see that io.swagger:swagger-jaxrs2:2.0.0-rc2 is nearing completion, which correctly pulls in (transitively) javax.ws.rs:javax.ws.rs-api:2.0.1. So I hope you can update to the new swagger-jaxrs2 dependency as soon as version 2 is released.