我使用Camel Jetty作为REST组件 . 对于jetty,您只需添加一个额外的ResourceHandler来处理SwaggerUI资源 . 下面使用Spring xml语言配置REST:
bindingMode="off" apiContextPath="api-docs" apiContextListing="true"
enableCORS="true">
......
......
我在webjars提供的jar中使用swaggerUI . 配置处理程序bean:
beans 厂:
public class JettyResourceHandlerFactory {
public static ResourceHandler buildResourceHandler(String resourcePath) throws Exception {
ResourceHandler rh = new ResourceHandler();
rh.setResourceBase(JettyResourceHandlerFactory.class.getClassLoader()
.getResource(resourcePath)
.toURI().toString());
return rh;
}
}