【发布时间】:2019-03-10 14:31:21
【问题描述】:
我正在尝试在预构建项目中设置 Swagger + Swagger UI,该项目既不使用 Jersey 2 容器 Servlet,也不使用 official docs 中所述的过滤器配置(使用 web.xml)。
我的主课是这样的:
public class Application {
public static void main(String[] args) {
URI uri = UriBuilder.fromUri("//localhost/").scheme("http").port(8080).build();
ResourceConfig resourceConfig = new ResourceConfig();
final HttpServer httpServer = JdkHttpServerFactory.createHttpServer(uri, resourceConfig, false);
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
httpServer.stop(0);
}));
httpServer.start();
}
}
我想使用包扫描和 Swagger UI 来跟踪我的 API。我找到的所有答案都表明您应该扩展Application 类或使用带有web.xml 文件的过滤器配置。请给我一个关于如何将 Swagger 添加到给我的现有项目的提示。
我是 JAX-RS 的新手,有点困惑......所以我请求理解。 :)
【问题讨论】:
标签: java jax-rs swagger jersey-2.0 swagger-ui