java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:1.8.0_242]
出現此錯誤,就是應該導入了多個版本的swagger依賴
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
通過IDEA提供的依賴圖查看,項目中存在 1.5.20版本和2.1.2版本,需要排除1.5.20版本的依賴;解決方法如下:替換swagger的依賴包即可
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> <exclusions> <exclusion> <artifactId>swagger-models</artifactId> <groupId>io.swagger</groupId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-common</artifactId> <version>3.0.0</version> <exclusions> <exclusion> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> </exclusion> <exclusion> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>3.0.0</version> <scope>compile</scope> <exclusions> <exclusion> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> </exclusion> <exclusion> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> </exclusion> </exclusions> </dependency>
因爲
springfox-boot-starter:3.0 依賴導入了2個版本,所以只需要把低版本排除即可