很多朋友在升级Springfox-Swagger到2.9.2版本后会碰见NumberFormatException异常java.lang.NumberFormatException: For input string: “”

    异常信息如下:

    1. java.lang.NumberFormatException: For input string: ""
    2. at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[na:1.8.0_111]
    3. at java.lang.Long.parseLong(Long.java:601) ~[na:1.8.0_111]
    4. at java.lang.Long.valueOf(Long.java:803) ~[na:1.8.0_111]
    5. at
    6. //more....

    解决办法是在pom.xml中排除Springfox-Swagger的Swagger-Models的jar包,重新引入,如下:

    1. <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
    2. <dependency>
    3. <groupId>io.springfox</groupId>
    4. <artifactId>springfox-swagger2</artifactId>
    5. <version>2.9.2</version>
    6. <exclusions>
    7. <exclusion>
    8. <groupId>io.swagger</groupId>
    9. <artifactId>swagger-models</artifactId>
    10. </exclusion>
    11. </exclusions>
    12. </dependency>
    13. <!-- https://mvnrepository.com/artifact/io.swagger/swagger-models -->
    14. <dependency>
    15. <groupId>io.swagger</groupId>
    16. <artifactId>swagger-models</artifactId>
    17. <version>1.5.21</version>
    18. </dependency>