0還有一個(gè)問題配置類容易被遺忘貼上配置類的注解?病(Configuration@EnableSwagger2)?
另一個(gè)時(shí)404時(shí)靜態(tài)資源配置問題:
1權(quán)限控制過程中被攔截了
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:
如圖:
這個(gè)問題是因?yàn)槟阆到y(tǒng)有安全鑒權(quán)導(dǎo)致(Shiro /Security)
解決方案:
1.放開對(duì)該頁面的鑒權(quán)
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的不同版本一直是個(gè)問題嵌赠。 在某些情況下塑荒,如2.5.0之前的版本和2.6.1版本的后者,集成工作正常姜挺。 但是齿税,如果前者是2.6.1而后者是2.4.0,則ui變得不相容炊豪。 因此凌箕,我建議如果兩個(gè)依賴關(guān)系都是通過實(shí)踐采用相同的版本,那么可以減少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項(xiàng)目沒有配置項(xiàng)目context-path:
解決給個(gè)默認(rèn)值 "/",或者配好您的context-path: /xxx
@Configuration@EnableSwagger2