一、异常分析:

Illegal DefaultValue null for parameter type integer`和`NumberFormatException: For input string: ""

从上面这句可以看出,有个默认值是空字符串的变量转换成Integer类型时异常。

at io.swagger.models.parameters.AbstractSerializableParameter.getExample(AbstractSerializableParameter.java:412) ~[swagger-models-1.5.20.jar:1.5.20]

根据上面这句报错信息,点进去AbstractSerializableParameter.java:412可以看到

if(BaseIntegerProperty.TYPE.equals(type)){

return Long.valueOf(example);

}

就是说如果实体属性类型是Integer,就把example转为Long类型,而example默认为"",导致转换错误。

二、解决办法:

方法一:
实体类中,Integer类型的属性加@ApiModelProperty时,必须要给example参数赋值,且值必须为数字类型。

@ApiModelProperty(value = "试卷ID",example = "1")
private int pageId;

  

方法二:

忽略原版本的swagger-annotations和swagger-models,添加1.5.21版本的

<!--swagger依赖-->

<dependency>

    <groupId>io.springfox</groupId>

    <artifactId>springfox-swagger2</artifactId>

    <version>2.9.2</version>

  <exclusions>

      <exclusion>

        <groupId>io.swagger</groupId>

        <artifactId>swagger-annotations</artifactId>

      </exclusion>

      <exclusion>

        <groupId>io.swagger</groupId>

        <artifactId>swagger-models</artifactId>

      </exclusion>

  </exclusions>

</dependency>

<!--解决进入swagger页面报类型转换错误,排除2.9.2中的引用,手动增加1.5.21版本-->

<dependency>

  <groupId>io.swagger</groupId>

  <artifactId>swagger-annotations</artifactId>

  <version>1.5.21</version>

</dependency>

<dependency>

  <groupId>io.swagger</groupId>

  <artifactId>swagger-models</artifactId>

  <version>1.5.21</version>

</dependency>

  

Swagger2异常:Illegal DefaultValue null for parameter type integer java的更多相关文章

  1. springboot集成swagger2报Illegal DefaultValue null for parameter type integer

    springboot集成swagger2,实体类中有int类型,会报" Illegal DefaultValue null for parameter type integer"的 ...

  2. swagger 报 i.s.m.parameters.AbstractSerializableParameter - Illegal DefaultValue null for parameter type integer java.lang.NumberFormatException: For input string

    解决 方法 添加这两个依赖....别问我有啥子用....我也不知道..能解决问题 <dependency> <groupId>io.swagger</groupId> ...

  3. 解决 Illegal DefaultValue null for parameter type integer 异常

    该异常是由 swagger 引起的 swagger 版本 1.9.2 解决原因:重新导入 swagger-annotations 和 swagger-models 版本 为 1.5.21 pom.xm ...

  4. swagger2 Illegal DefaultValue null for parameter type integer

    问题,为了方便调试,引入了swagger2,但是在第一次访问的时候总是报 Illegal DefaultValue null for parameter type integer 让人看着很不输入 定 ...

  5. swagger 报错:illegal defaultValue null for param type integer

    swagger(版本2.9.2) 刷新报错,错误信息如下图: 问题原因: 根据上面这句报错信息,点进去AbstractSerializableParameter.java:412可以看到 源码, @J ...

  6. MyBatis报错—Type handler was null on parameter mapping for property 'createTime'. It was either not specified and/or could not be found for the javaType (javax.xml.crypto.Data) : jdbcType (null) combina

    原因是:在创建实体类的时候吧date类型写成data导致类型不匹配 Type handler was null on parameter mapping for property 'createTim ...

  7. 操作MyBatis引发Error setting null for parameter #X with JdbcType OTHER .无效的列类型

    再用MyBatis操作Oracle的时候,传入null值而引发的错误 异常信息: org.springframework.jdbc.UncategorizedSQLException: Error s ...

  8. URLDecoder异常Illegal hex characters in escape (%)

    URLDecoder对参数进行解码时候,代码如: URLDecoder.decode(param,"utf-8"); 有时候会出现类似如下的错误: URLDecoder异常Ille ...

  9. Error setting null for parameter #10 with JdbcType

    转: Error setting null for parameter #10 with JdbcType OTHER . 2014年02月23日 11:00:33 厚积 阅读数 58535   my ...

随机推荐

  1. <<代码大全>>阅读笔记之二 变量名的力量

    1.变量命名的注意事项 1)可理解性 变量要望文知义,看到这个变量不用看其他的代码就知道这个变量表示什么意思 好的变量命:currentDate, heartRate 糟糕的变量名:newButton ...

  2. [Spring Boot] Set Context path for application in application.properties

    If you were using Microservice with Spring Boot to build different REST API endpoints, context path ...

  3. PHP mysqli_get_client_info() 函数

    定义和用法 mysqli_get_client_info() 函数返回 MySQL 客户端库版本. <?php echo mysqli_get_client_info(); ?>

  4. 使用StringBuilder写XML遭遇UTF-16问题

     http://www.cnblogs.com/jans2002/archive/2007/08/05/843843.html

  5. Codevs 3012 线段覆盖 4

    3012 线段覆盖 4 时间限制: 1 s 空间限制: 64000 KB 题目等级 : 黄金 Gold 题目描述 Description 数轴上有n条线段,线段的两端都是整数坐标,坐标范围在0~100 ...

  6. spring boot+idea实现程序热部署

    pring为开发者提供了一个名为spring-boot-devtools的模块来使Spring Boot应用支持热部署,提高开发者的开发效率,无需手动重启Spring Boot应用. devtools ...

  7. ios端,input框,汉字输入不上问题

    input{ -webkit-transform: translate3d(, , ); } 在input框上加上这段代码就可以了 另外,我在一个页面上,用一个开关去控制一部分内容显示隐藏与显示时,当 ...

  8. 在iOS开发中使用icon font的方法

    http://iconfont.cn/help/iconuse.html 在开发阿里数据iOS版客户端的时候,由于项目进度很紧,项目里的所有图标都是用最平常的背景图片方案来实现.而为了要兼容普通屏与R ...

  9. python并发——进程间同步和通信

    一.进程间同步 对于一些临界资源,不能使用并发无限消耗,就需要设置专门的临界标示,比如锁或者信号量等 from multiprocessing import Process, Lock import ...

  10. java按某个字段对数据分组

    import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; i ...