Unable to scan documentation context default java.lang.IllegalStateException: Ambiguous models equality when conditions is empty. at springfox.documentation.spring.web.scanners.ApiModelReader.checkCondition(ApiModelReader.java:618) at springfox.documentation.spring.web.scanners.ApiModelReader.mergeConditions(ApiModelReader.java:385) at springfox.documentation.spring.web.scanners.ApiModelReader.mergeModelBranch(ApiModelReader.java:255)
时间: 2023-10-03 15:02:19 浏览: 373
这个错误通常是由于Springfox的版本不兼容造成的。你可以尝试升级Springfox的版本,或者降级Springfox的版本来解决问题。
另外,你也可以在Springfox中禁用ApiModelReader来解决此问题。你可以在配置类中添加以下代码:
```
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo())
.ignoredParameterTypes(YourIgnoredClass.class)
.directModelSubstitute(YourModel.class, YourModelDto.class)
.useDefaultResponseMessages(false)
.enableUrlTemplating(true)
.alternateTypeRules(
newRule(typeResolver.resolve(DeferredResult.class,
typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
typeResolver.resolve(WildcardType.class)))
.ignoredParameterTypes(Pageable.class, Slice.class, Sort.class)
.genericModelSubstitutes(ResponseEntity.class)
.forCodeGeneration(true)
.protocols(new HashSet<>(Arrays.asList("http", "https")))
.tags(new Tag("users", "Operations about users"))
.additionalModels(typeResolver.resolve(AdditionalModel.class))
.groupName("test-group")
.directModelSubstitute(LocalDate.class, Date.class)
.directModelSubstitute(LocalDateTime.class, Date.class)
.apiModelReader(null);
}
```
注意最后一行代码 `apiModelReader(null)` 将禁用ApiModelReader。
阅读全文