找不到与密钥匹配的型号 [英] Unable to find a model that matches key
本文介绍了找不到与密钥匹配的型号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据以下步骤将Swagger从2.9.2升级到3.0.0:
https://springfox.github.io/springfox/docs/snapshot/#migrating-from-existing-2-x-version
在新版本中,虽然功能运行正常,但当点击";/swagger-ui/index.html";时,日志中会显示以下错误。
使用springfox-boot-starter 3.0.0。非常感谢您的意见。
[ReferenceModelSpecificationToPropertyConverter]找不到 与密钥匹配的型号 ModelKey{qualifiedModelName=ModelName{namespace=‘java.time’, Name=‘LocalDate’},view Disciplator=NULL, ValidationGroupDisdicator=[],isResponse=True}
推荐答案
不确定是否属于您的情况,但对我来说,出现此问题是因为我有一个JsonSubTyped泛型继承,其中一个子级将List和List<;LocalDateTime;作为其参数。对我来说,解决方法是为类型包括额外的规则,如下所示:
myDocket.alternateTypeRules(
AlternateTypeRules.newRule(typeResolver.resolve(List.class, LocalDate.class), typeResolver.resolve(List.class, java.sql.Date.class)),
AlternateTypeRules.newRule(typeResolver.resolve(List.class, LocalDateTime.class), typeResolver.resolve(List.class, java.util.Date.class)))
替换类来自官方网站。
这篇关于找不到与密钥匹配的型号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文