我不明白你为什么用2
org.glassfish.jersey.servlet.ServletContainer
这行不通
通过在web.xml中提及,确保您提到的自定义应用程序是通过jersey容器加载的
swagger-jersey2-jaxrs
依赖性将足够了,其余部分将通过传递方式删除。我不知道你正在使用哪个版本的球衣,但你必须扩展
ResourceConfig
Application
类本身
您必须在扩展资源配置中注册这两个功能
io.swagger.jaxrs.listing.ApiListingResource,
io.swagger.jaxrs.listing.SwaggerSerializers
您的自定义应用程序类必须在web中提及。像这样的xml
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.foo.app.CustomApplication
</param-value>
</init-param>
</servlet>
url: "http://localhost:8080/OpenEMPIStorage/rest/api-docs",
url: "swagger.json"
http://localhost:8080/OpenEMPIStorage/rest/api-docs
是在这个昂首阔步复制。json文件
public MyRestApplication()
{
System.out.println("Entering Custom Application");
property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
// @ValidateOnExecution annotations on subclasses won't cause errors.
property(ServerProperties.BV_DISABLE_VALIDATE_ON_EXECUTABLE_OVERRIDE_CHECK, true);
register(RolesAllowedDynamicFeature.class);
register(AuthenticationFilter.class);
register(AuthenticationResponseFilter.class);
}
不要使用
@ApplicationPath
你的傲慢。json应该在fallowing path下可用
http://<ip address:portname or domain name >/<yourapp-path>/dgs/swagger.json