Swagger2(2.9版本)集成springboot(2.3.7版本)出现Illegal DefaultValue null for parameter type integer异常

在使用Swagger2.9的过程中,出现Illegal DefaultValue null for parameter type integer

在网上查找了解决办法,说是空字符串转换integer异常,需要在相应的integer字段加上@ApiModelProperty注解,然后加上属性 example = "1",但是方法无效,依旧出错。

后来在springfox的github上找到解决办法,特此记录一下:

  issue上认为,swagger-models-1.5.20.jar 这个包有bug或者其他原因造成的,所以需要我们自己更正新的包

复制代码
 1 <dependency>
 2     <groupId>io.springfox</groupId>
 3     <artifactId>springfox-swagger2</artifactId>
 4     <version>2.9.2</version>
 5 <!--先是排除有问题的包-->
 6     <exclusions>
 7         <exclusion>
 8             <groupId>io.swagger</groupId>
 9             <artifactId>swagger-annotations</artifactId>
10         </exclusion>
11         <exclusion>
12             <groupId>io.swagger</groupId>
13             <artifactId>swagger-models</artifactId>
14         </exclusion>
15     </exclusions>
16 </dependency>
17 <dependency>
18     <groupId>io.springfox</groupId>
19     <artifactId>springfox-swagger-ui</artifactId>
20     <version>2.9.2</version>
21 </dependency>
22 <!--然后手动加入没问题的包-->
23 <dependency>
24     <groupId>io.swagger</groupId>
25     <artifactId>swagger-annotations</artifactId>
26     <version>1.5.21</version>
27 </dependency>
28 <dependency>
29     <groupId>io.swagger</groupId>
30     <artifactId>swagger-models</artifactId>
31     <version>1.5.21</version>
32 </dependency>
复制代码

就这样,问题KO,在查找问题的过程中,发现,只要错误提示的代码不是自己写的,大部分最后查出来都是依赖冲突或者那个包本来就有bug之类的,算是给自己排查问题提供了一个方向

posted @   huang1993  阅读(445)  评论(0编辑  收藏  举报
编辑推荐:
· 没有源码,如何修改代码逻辑?
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
阅读排行:
· DeepSeek “源神”启动!「GitHub 热点速览」
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器
点击右上角即可分享
微信分享提示