5
我有一個運行在http://localhost:8080/MyService
上的REST API,可以看到http://localhost:8080/MyService/api-docs
上由swagger生成的JSON。在Eclipse的服務器項目,我已經修改web.xml中包含CORS廣告過濾:如何使用swagger-ui與在eclipse上運行的tomcat中部署的服務
<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
點招搖的用戶界面(從文件系統加載到瀏覽器),我收到以下錯誤:
Can't read from server. It may not have the appropriate access-control-origin settings.
此解決方案不起作用。 –
請詳細說明您的設置。上述解決方案爲我工作... –
您的解決方案可能適用於大多數情況下,但在一般情況下沒有。 swagger-jaxrs_2.10和resteasy-jaxrs的最新版本之間存在衝突。這一修改在pom.xml中解決問題 com.wordnik 招搖,jaxrs_2.10 $ {} swagger.version javax.ws.rs jsr311- api –