swagger.models 报:java.lang.NumberFormatException: For input string: ““

swagger.models 报:java.lang.NumberFormatException: For input string: ""

2020-09-15 15:33:16 [http-nio-6143-exec-4] WARN  io.swagger.models.parameters.AbstractSerializableParameter - Illegal DefaultValue null for parameter type integer
java.lang.NumberFormatException: For input string: ""
	at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) ~[?:1.8.0_201]
	at java.lang.Long.parseLong(Long.java:601) ~[?:1.8.0_201]
	at java.lang.Long.valueOf(Long.java:803) ~[?:1.8.0_201]
	at io.swagger.models.parameters.AbstractSerializableParameter.getExample(AbstractSerializableParameter.java:412) [swagger-models-1.5.20.jar:1.5.20

pom文件

		<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>

点击会看到

  <modelVersion>4.0.0</modelVersion>
  <groupId>io.springfox</groupId>
  <artifactId>springfox-swagger2</artifactId>
  <version>2.9.2</version>
  <dependencies>
    <dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-annotations</artifactId>
      <version>1.5.20</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-models</artifactId>
      <version>1.5.20</version>
      <scope>compile</scope>
    </dependency>

解决: 把swagger2里面自带的models替换掉

<!--swagger2-->
		<dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
            <exclusions><!--把swagger2里面自带的models、annotations替换掉-->
                <exclusion>
                    <groupId>io.swagger</groupId>
                    <artifactId>swagger-models</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.swagger</groupId>
                    <artifactId>swagger-annotations</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-models</artifactId>
            <version>1.5.22</version>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
            <version>1.5.22</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>

github:(后期上传:配置类、测试类)

猜你喜欢

转载自blog.csdn.net/qq_42476834/article/details/108600687