如何使用swagger-ui与在eclipse上运行的tomcat中部署的服务

时间:2014-01-09 10:45:14

标签: rest tomcat web-applications swagger swagger-ui

我在http://localhost:8080/MyService运行了一个REST api,可以在http://localhost:8080/MyService/api-docs看到swagger生成的JSON。在eclipse的Servers项目中,我修改了web.xml以包含Cors过滤器:

<filter>
    <filter-name>CorsFilter</filter-name>
    <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>CorsFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

但是当我在http://localhost:8080/MyService/api-docs指向swagger-ui(从文件系统的浏览器加载)时,我收到以下错误:

  

无法从服务器读取。它可能没有合适的   访问控制原点设置。

1 个答案:

答案 0 :(得分:4)

将Swagger dist直接添加到webapps文件夹就可以了解

相关问题