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个版本,所以只需要把低版本排除即可