Error creating bean with name ‘apiModelSpecificationReader‘ defined in URL

问题:

        启动项目的时候,报错了

org.springframework.beans.factory.UnsatisfiedDependencyException: 
Error creating bean with name 'apiModelSpecificationReader' defined in URL 
[jar:file:/D:/.gradle/caches/modules-2/files-2.1/io.springfox/springfox-spring-web/3.0.0/a76f2fbe805bfd2798e20dc8f2cfbfad554d52da/springfox-spring-web-3.0.0.jar!/springfox/documentation/spring/web/scanners/ApiModelSpecificationReader.class]: 
Unsatisfied dependency expressed through constructor parameter 0; nested exception is 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 
'springfox.documentation.schema.ModelSpecificationProvider' available: expected at least 1 
bean which qualifies as autowire candidate. Dependency annotations: 
{@org.springframework.beans.factory.annotation.Qualifier(value=cachedModels)}

        检查了下swagger的版本,用的是:

    implementation("io.swagger:swagger-annotations:1.5.20")
    implementation("io.springfox:springfox-swagger2:2.9.2")
    implementation("io.springfox:springfox-swagger-ui:2.9.2")
    implementation("io.springfox:springfox-swagger-common:2.9.2")

        提示却是3.0.0

[jar:file:/D:/.gradle/caches/modules-2/files-2.1/
io.springfox/springfox-spring-web/3.0.0

复制了下路径,检查了下,确实是如此。

原来是新的项目swagger用的是3.0.0,用的是一样的路径,导致影响。 

处理1:

        把springfox-spring-web目录下的3.0.0目录删了,再启动,是正常的。

        但这样的话,有弄先的项目,又会出问题。

处理2:

        在build.grale文件里面添加:  exclude group: 'io.springfox', module: 'springfox-boot-starter'

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
    all {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
        exclude group: 'ch.qos.logback'
        exclude group: 'org.apache.solr'
        exclude group: 'io.springfox', module: 'springfox-boot-starter'
    }
}

这样启动就不受影响了。

总结:

        启动报Error creating bean with name 'apiModelSpecificationReader' defined in URL 是版本不一致的问题,加个去除对应模块去处理:exclude group: 'io.springfox', module: 'springfox-boot-starter'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天狼1222

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值