今天寫東西的時候發現一個Swagger2的問題,其他什麼都正常的情況下,Swagger2的依賴寫成如下
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
這樣總是報錯:Parameter 0 of method linkDiscoverers in org.springframework.hateoas.config.HateoasConfiguration req
xxxxx
…
一大堆 = null
後來我想起來之前也是Swagger2的錯誤,由於兩個依賴順序寫反了,就報各種錯。然後我就想依賴調換順序:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
然後果然不報錯了。。。。。
但是當我又試着展現錯誤的情況而將兩個依賴順序再次顛倒爲“錯的順序”時,我發現又能正常運行了。。。
注意:springboot版本爲2.2.0+,swagger版本爲2.2.2就會報這個錯誤
建議將swagger版本改爲2.9.2