首页 > 解决方案 > Springfox Boot Starter 3.0.0 JsonSerializer 错误

问题描述

我在我的项目中使用io.springfox 3.0.0 版本。我将依赖项添加到我的 build.gradle 文件中,如下所示:

implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'

外部库按预期创建:

io.springfox:springfox-boot-starter:3.0.0
io.springfox:springfox-core:3.0.0
io.springfox:springfox-data-rest:3.0.0
io.springfox:springfox-oas:3.0.0
io.springfox:springfox-schema:3.0.0
io.springfox:springfox-spi:3.0.0
io.springfox:springfox-spring-web:3.0.0
io.springfox:springfox-spring-web-flux:3.0.0
io.springfox:springfox-spring-web-mvc:3.0.0
io.swagger.core.v3:swagger-annotation:2.1.2
io.swagger.core.v3:swagger-models:2.1.2

我正在使用 Spring Boot 2.4.2 和 Java 11。

当我运行我的 Spring Boot 应用程序时,我收到以下错误:

org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“swagger2ControllerWebMvc”的 bean 在 URL [jar:file:/opt/rally/dynamicscreen-service/lib/springfox-swagger2.jar!/springfox/documentation/swagger2/ 中定义时出错web/Swagger2ControllerWebMvc.class]:通过构造函数参数2表示的不满足的依赖关系;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在 springfox.documentation.spring.web.SpringfoxWebConfiguration 中创建名称为“jsonSerializer”的 bean 时出错:通过工厂方法实例化 bean 失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [springfox.documentation.spring.web.json.JsonSerializer]:工厂方法 'jsonSerializer' 抛出异常;嵌套异常是 java.lang。

我哪里做错了?

标签: spring-bootswaggeropenapispringfoxswagger-3.0

解决方案


推荐阅读