解決swagger2集成問題,404,1彈窗問題,2啟動項目報錯,3啟動后頻繁打印錯誤日志 /null/swagger-ui.html,

0還有一個問題配置類容易被遺忘貼上配置類的注解?。–onfiguration@EnableSwagger2)?

另一個時404時靜態(tài)資源配置問題:



404需要復寫MVC映射

1權限控制過程中被攔截了

Unable to infer base url. This is common when using dynamic servlet registration or when the API is behind an API Gateway. The base url is the root of where all the swagger resources are served. For e.g. if the api is available at http://example.org/api/v2/api-docs then the base url is http://example.org/api/. Please enter the location manually:

如圖:


這個問題是因為你系統(tǒng)有安全鑒權導致(Shiro /Security)

解決方案:

1.放開對該頁面的鑒權



2版本與springBoot(Spring 不兼容造成的)

解決方法:

So you're better off using 2.5.0 in both versions as it has a lot of issues fixed compared!

原文:https://stackoverflow.com/questions/38744115/no-mapping-found-for-swagger-resources-configuration-ui

Different versioning of springfox-swagger2 and springfox-swagger-ui has been an issue. In some cases, like former of 2.5.0 and latter of 2.6.1 version, the integration works fine. But, if former is of 2.6.1 and latter is of 2.4.0, then the ui becomes incompatible. Hence, I suggest if both the dependencies are taken of same version by practice, then unexpected functioning of swagger can be reduced.

中文:springfox-swagger2和springfox-swagger-ui的不同版本一直是個問題。 在某些情況下,如2.5.0之前的版本和2.6.1版本的后者,集成工作正常。 但是,如果前者是2.6.1而后者是2.4.0,則ui變得不相容。 因此,我建議如果兩個依賴關系都是通過實踐采用相同的版本,那么可以減少swagger的意外功能。

------------------------------------------------------------------------------------------------------------------------

<dependency>??

<groupId>io.springfox</groupId>??

<artifactId>springfox-swagger2</artifactId>??

<version>2.5.0</version>??

</dependency>??

<dependency>??

<groupId>io.springfox</groupId>??

<artifactId>springfox-swagger-ui</artifactId>??

<version>2.5.0</version>??

</dependency>?

------------------------------------------------------------------------------------------------------------------------

3項目沒有配置項目context-path:

解決給個默認值 "/",或者配好您的context-path: /xxx


servr.context-path


@Configuration@EnableSwagger2

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容