問題1:控制台日志輸出告警,頁面按F12打開swagger控制台"/","/csrf"兩個404接口
No mapping found for HTTP request with uri [/xxx/csrf] in Dispatcherservlet with name 'dispatcherservlet'

解決方案:
這個問題在 2.9.x 版本中有,暫時還沒有找到好的解決方案,回退到 2.8.0 版本解決
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
問題2:項目啟動報錯
Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is com.google.common.util.concurrent.ExecutionError:java.lang.NoSuchMethodError
解決方案:
原因是guava這個包沖突,回退到 2.8.0 版本解決
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
或者統一guava版本
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>
問題3:通路swagger會報錯
java.lang.NumberFormatException: For input string: ""
解決方案:
原因@ApiModelProperty 中無 example 會報 NumberFormatException 的異常,版本bug,回退到 2.8.0 版本解決
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
或者用老版本替換
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.22</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.22</version>
</dependency>
總結:高版本有些沒遇到的問題,可以回退低版本