【问题标题】:Failed to start bean 'documentationPluginsBootstrapper' in spring data rest无法在春季数据休息中启动 bean 'documentationPluginsBootstrapper'
【发布时间】:2017-03-07 14:43:27
【问题描述】:

我正在为我的应用程序使用 spring data rest。

当我在存储库中添加此方法时,我收到以下错误并且应用程序没有启动:-

方法:-

@Modifying
@Transactional
@Query("from employee as ft where ft.company.id = ?1")
void deleteAllEmployeeCompany(
        @Param("companyId") @RequestParam("companyId") int companyId);

错误:-

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:176) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:51) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:346) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:149) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:112) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:874) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh(EmbeddedWebApplicationContext.java:144) ~[spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544) ~[spring-context-4.3.3.RELEASE.jar!/:4.3.3.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.1.RELEASE.jar!/:1.4.1.RELEASE]

如何解决?

更新:-

所有依赖项列表:-

[INFO] com.test:test-service:jar:0.0.1-SNAPSHOT
[INFO] +- org.springframework.boot:spring-boot-starter-actuator:jar:1.4.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:1.4.1.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot:jar:1.4.1.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-autoconfigure:jar:1.4.1.RELEASE:compile
[INFO] |  |  \- org.springframework.boot:spring-boot-starter-logging:jar:1.4.1.RELEASE:compile
[INFO] |  |     +- ch.qos.logback:logback-classic:jar:1.1.7:compile
[INFO] |  |     |  \- ch.qos.logback:logback-core:jar:1.1.7:compile
[INFO] |  |     +- org.slf4j:jul-to-slf4j:jar:1.7.21:compile
[INFO] |  |     \- org.slf4j:log4j-over-slf4j:jar:1.7.21:compile
[INFO] |  \- org.springframework.boot:spring-boot-actuator:jar:1.4.1.RELEASE:compile
[INFO] |     \- org.springframework:spring-context:jar:4.3.3.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-jpa:jar:1.4.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-aop:jar:1.4.1.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-aop:jar:4.3.3.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:1.4.1.RELEASE:compile
[INFO] |  |  +- org.apache.tomcat:tomcat-jdbc:jar:8.5.5:compile
[INFO] |  |  |  \- org.apache.tomcat:tomcat-juli:jar:8.5.5:compile
[INFO] |  |  \- org.springframework:spring-jdbc:jar:4.3.3.RELEASE:compile
[INFO] |  +- org.hibernate:hibernate-core:jar:5.0.11.Final:compile
[INFO] |  |  +- org.jboss.logging:jboss-logging:jar:3.3.0.Final:compile
[INFO] |  |  +- org.hibernate.javax.persistence:hibernate-jpa-2.1-api:jar:1.0.0.Final:compile
[INFO] |  |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  |  +- org.jboss:jandex:jar:2.0.0.Final:compile
[INFO] |  |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  |  |  \- xml-apis:xml-apis:jar:1.4.01:compile
[INFO] |  |  \- org.hibernate.common:hibernate-commons-annotations:jar:5.0.1.Final:compile
[INFO] |  +- org.hibernate:hibernate-entitymanager:jar:5.0.11.Final:compile
[INFO] |  +- javax.transaction:javax.transaction-api:jar:1.2:compile
[INFO] |  +- org.springframework.data:spring-data-jpa:jar:1.10.3.RELEASE:compile
[INFO] |  |  +- org.springframework.data:spring-data-commons:jar:1.12.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-orm:jar:4.3.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-tx:jar:4.3.3.RELEASE:compile
[INFO] |  |  +- org.springframework:spring-beans:jar:4.3.3.RELEASE:compile
[INFO] |  |  \- org.slf4j:jcl-over-slf4j:jar:1.7.21:compile
[INFO] |  \- org.springframework:spring-aspects:jar:4.3.3.RELEASE:compile
[INFO] +- org.springframework.boot:spring-boot-starter-data-rest:jar:1.4.1.RELEASE:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.8.3:compile
[INFO] |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.8.3:compile
[INFO] |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.8.3:compile
[INFO] |  \- org.springframework.data:spring-data-rest-webmvc:jar:2.5.3.RELEASE:compile
[INFO] |     \- org.springframework.data:spring-data-rest-core:jar:2.5.3.RELEASE:compile
[INFO] |        \- org.atteo:evo-inflector:jar:1.2.1:compile
[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:1.4.1.RELEASE:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:1.4.1.RELEASE:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.5:compile
[INFO] |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.5:compile
[INFO] |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.5:compile
[INFO] |  +- org.hibernate:hibernate-validator:jar:5.2.4.Final:compile
[INFO] |  |  \- javax.validation:validation-api:jar:1.1.0.Final:compile
[INFO] |  +- org.springframework:spring-web:jar:4.3.3.RELEASE:compile
[INFO] |  \- org.springframework:spring-webmvc:jar:4.3.3.RELEASE:compile
[INFO] |     \- org.springframework:spring-expression:jar:4.3.3.RELEASE:compile
[INFO] +- org.springframework.cloud:spring-cloud-starter-eureka:jar:1.1.0.RELEASE:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-starter:jar:1.1.0.RELEASE:compile
[INFO] |  |  +- org.springframework.cloud:spring-cloud-context:jar:1.1.0.RELEASE:compile
[INFO] |  |  |  \- org.springframework.security:spring-security-crypto:jar:4.1.3.RELEASE:compile
[INFO] |  |  +- org.springframework.cloud:spring-cloud-commons:jar:1.1.0.RELEASE:compile
[INFO] |  |  \- org.springframework.security:spring-security-rsa:jar:1.0.1.RELEASE:compile
[INFO] |  |     \- org.bouncycastle:bcpkix-jdk15on:jar:1.47:compile
[INFO] |  |        \- org.bouncycastle:bcprov-jdk15on:jar:1.47:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-netflix-core:jar:1.1.0.RELEASE:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-netflix-eureka-client:jar:1.1.0.RELEASE:compile
[INFO] |  +- com.netflix.eureka:eureka-client:jar:1.4.6:compile
[INFO] |  |  +- org.codehaus.jettison:jettison:jar:1.3.7:runtime
[INFO] |  |  |  \- stax:stax-api:jar:1.0.1:runtime
[INFO] |  |  +- com.netflix.netflix-commons:netflix-eventbus:jar:0.3.0:runtime
[INFO] |  |  +- com.netflix.archaius:archaius-core:jar:0.7.4:compile
[INFO] |  |  +- javax.ws.rs:jsr311-api:jar:1.1.1:runtime
[INFO] |  |  +- com.netflix.servo:servo-core:jar:0.10.1:runtime
[INFO] |  |  |  \- com.netflix.servo:servo-internal:jar:0.10.1:runtime
[INFO] |  |  +- com.sun.jersey:jersey-core:jar:1.19.1:runtime
[INFO] |  |  +- com.sun.jersey:jersey-client:jar:1.19.1:runtime
[INFO] |  |  +- com.sun.jersey.contribs:jersey-apache-client4:jar:1.19.1:runtime
[INFO] |  |  +- org.apache.httpcomponents:httpclient:jar:4.5.2:compile
[INFO] |  |  |  +- org.apache.httpcomponents:httpcore:jar:4.4.5:compile
[INFO] |  |  |  \- commons-codec:commons-codec:jar:1.10:compile
[INFO] |  |  +- com.google.inject:guice:jar:4.0:runtime
[INFO] |  |  |  +- javax.inject:javax.inject:jar:1:runtime
[INFO] |  |  |  \- aopalliance:aopalliance:jar:1.0:runtime
[INFO] |  |  \- com.netflix.governator:governator-api:jar:1.12.10:runtime
[INFO] |  +- com.netflix.eureka:eureka-core:jar:1.4.6:compile
[INFO] |  |  +- com.amazonaws:aws-java-sdk-core:jar:1.10.30:runtime
[INFO] |  |  +- com.amazonaws:aws-java-sdk-ec2:jar:1.10.30:runtime
[INFO] |  |  +- com.amazonaws:aws-java-sdk-autoscaling:jar:1.9.3:runtime
[INFO] |  |  +- com.amazonaws:aws-java-sdk-sts:jar:1.9.3:runtime
[INFO] |  |  +- com.amazonaws:aws-java-sdk-route53:jar:1.9.3:runtime
[INFO] |  |  +- com.netflix.governator:governator:jar:1.12.10:runtime
[INFO] |  |  |  +- com.netflix.governator:governator-core:jar:1.12.10:runtime
[INFO] |  |  |  \- org.ow2.asm:asm:jar:5.0.4:compile
[INFO] |  |  \- org.codehaus.woodstox:woodstox-core-asl:jar:4.4.1:runtime
[INFO] |  |     +- javax.xml.stream:stax-api:jar:1.0-2:runtime
[INFO] |  |     \- org.codehaus.woodstox:stax2-api:jar:3.1.4:runtime
[INFO] |  +- org.springframework.cloud:spring-cloud-starter-archaius:jar:1.1.0.RELEASE:compile
[INFO] |  |  \- commons-configuration:commons-configuration:jar:1.8:compile
[INFO] |  |     +- commons-lang:commons-lang:jar:2.6:compile
[INFO] |  |     \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] |  +- org.springframework.cloud:spring-cloud-starter-ribbon:jar:1.1.0.RELEASE:compile
[INFO] |  |  +- com.netflix.ribbon:ribbon:jar:2.1.5:compile
[INFO] |  |  |  +- com.netflix.ribbon:ribbon-transport:jar:2.1.5:runtime
[INFO] |  |  |  |  +- io.reactivex:rxnetty-contexts:jar:0.4.9:runtime
[INFO] |  |  |  |  \- io.reactivex:rxnetty-servo:jar:0.4.9:runtime
[INFO] |  |  |  \- io.reactivex:rxnetty:jar:0.4.9:runtime
[INFO] |  |  |     +- io.netty:netty-codec-http:jar:4.0.27.Final:runtime
[INFO] |  |  |     |  +- io.netty:netty-codec:jar:4.0.27.Final:runtime
[INFO] |  |  |     |  \- io.netty:netty-handler:jar:4.0.27.Final:runtime
[INFO] |  |  |     \- io.netty:netty-transport-native-epoll:jar:4.0.27.Final:runtime
[INFO] |  |  |        +- io.netty:netty-common:jar:4.0.27.Final:runtime
[INFO] |  |  |        +- io.netty:netty-buffer:jar:4.0.27.Final:runtime
[INFO] |  |  |        \- io.netty:netty-transport:jar:4.0.27.Final:runtime
[INFO] |  |  +- com.netflix.ribbon:ribbon-core:jar:2.1.5:compile
[INFO] |  |  +- com.netflix.ribbon:ribbon-httpclient:jar:2.1.5:compile
[INFO] |  |  |  \- com.netflix.netflix-commons:netflix-commons-util:jar:0.1.1:runtime
[INFO] |  |  +- com.netflix.ribbon:ribbon-loadbalancer:jar:2.1.5:compile
[INFO] |  |  |  \- com.netflix.netflix-commons:netflix-statistics:jar:0.1.1:runtime
[INFO] |  |  \- io.reactivex:rxjava:jar:1.1.5:compile
[INFO] |  +- com.netflix.ribbon:ribbon-eureka:jar:2.1.5:compile
[INFO] |  \- com.thoughtworks.xstream:xstream:jar:1.4.2:compile
[INFO] |     +- xmlpull:xmlpull:jar:1.1.3.1:compile
[INFO] |     \- xpp3:xpp3_min:jar:1.1.4c:compile
[INFO] +- org.springframework.boot:spring-boot-starter-amqp:jar:1.4.1.RELEASE:compile
[INFO] |  +- org.springframework:spring-messaging:jar:4.3.3.RELEASE:compile
[INFO] |  \- org.springframework.amqp:spring-rabbit:jar:1.6.2.RELEASE:compile
[INFO] |     +- com.rabbitmq:amqp-client:jar:3.6.3:compile
[INFO] |     +- org.springframework.retry:spring-retry:jar:1.1.4.RELEASE:compile
[INFO] |     +- com.rabbitmq:http-client:jar:1.0.0.RELEASE:compile
[INFO] |     \- org.springframework.amqp:spring-amqp:jar:1.6.2.RELEASE:compile
[INFO] +- com.netflix.hystrix:hystrix-javanica:jar:1.3.16:compile
[INFO] |  +- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] |  +- org.aspectj:aspectjweaver:jar:1.8.9:compile
[INFO] |  +- com.google.guava:guava:jar:18.0:compile
[INFO] |  +- com.netflix.hystrix:hystrix-core:jar:1.5.2:compile
[INFO] |  |  \- org.hdrhistogram:HdrHistogram:jar:2.1.7:compile
[INFO] |  \- org.apache.commons:commons-lang3:jar:3.1:compile
[INFO] +- com.netflix.hystrix:hystrix-metrics-event-stream:jar:1.3.16:compile
[INFO] |  \- org.codehaus.jackson:jackson-core-asl:jar:1.9.2:compile
[INFO] +- io.springfox:springfox-swagger2:jar:2.6.0:compile
[INFO] |  +- io.swagger:swagger-annotations:jar:1.5.10:compile
[INFO] |  +- io.swagger:swagger-models:jar:1.5.10:compile
[INFO] |  +- io.springfox:springfox-spi:jar:2.6.0:compile
[INFO] |  |  \- io.springfox:springfox-core:jar:2.6.0:compile
[INFO] |  +- io.springfox:springfox-schema:jar:2.6.0:compile
[INFO] |  +- io.springfox:springfox-swagger-common:jar:2.6.0:compile
[INFO] |  +- io.springfox:springfox-spring-web:jar:2.6.0:compile
[INFO] |  +- com.fasterxml:classmate:jar:1.3.1:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.21:compile
[INFO] |  +- org.springframework.plugin:spring-plugin-core:jar:1.2.0.RELEASE:compile
[INFO] |  +- org.springframework.plugin:spring-plugin-metadata:jar:1.2.0.RELEASE:compile
[INFO] |  \- org.mapstruct:mapstruct:jar:1.0.0.Final:compile
[INFO] +- io.springfox:springfox-swagger-ui:jar:2.6.0:compile
[INFO] +- io.springfox:springfox-data-rest:jar:2.6.0:compile
[INFO] |  \- org.springframework.hateoas:spring-hateoas:jar:0.20.0.RELEASE:compile
[INFO] +- org.liquibase:liquibase-core:jar:3.5.1:compile
[INFO] |  \- org.yaml:snakeyaml:jar:1.17:compile
[INFO] +- mysql:mysql-connector-java:jar:5.1.34:runtime
[INFO] +- org.springframework.boot:spring-boot-starter-test:jar:1.4.1.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:1.4.1.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:1.4.1.RELEASE:test
[INFO] |  +- junit:junit:jar:4.12:test
[INFO] |  +- org.assertj:assertj-core:jar:2.5.0:test
[INFO] |  +- org.mockito:mockito-core:jar:1.10.19:test
[INFO] |  |  \- org.objenesis:objenesis:jar:2.1:test
[INFO] |  +- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] |  +- org.hamcrest:hamcrest-library:jar:1.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.3.0:test
[INFO] |  |  \- org.json:json:jar:20140107:test
[INFO] |  +- org.springframework:spring-core:jar:4.3.3.RELEASE:compile
[INFO] |  \- org.springframework:spring-test:jar:4.3.3.RELEASE:test
[INFO] +- com.jayway.jsonpath:json-path:jar:2.2.0:compile
[INFO] |  \- net.minidev:json-smart:jar:2.2.1:compile
[INFO] |     \- net.minidev:accessors-smart:jar:1.1:compile
[INFO] \- org.reflections:reflections:jar:0.9.10:compile
[INFO]    +- org.javassist:javassist:jar:3.20.0-GA:compile
[INFO]    \- com.google.code.findbugs:annotations:jar:2.0.1:compile

【问题讨论】:

  • 不肯定就是这样,但= ?1 在您的查询中实际上不应该是= :companyId 吗?

标签: java spring spring-mvc spring-data springfox


【解决方案1】:

我在使用 springfox-swagger2 和 springfox-swagger-ui 版本(3.0.0)、spring-boot 版本(2.6.2)时遇到了同样的问题

解决此问题的方法是在应用程序中添加路径匹配器。 properties 或 application.yml

对于 application.properties:

spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER

对于 application.yml:

spring:
    mvc:
      pathmatch:
            matching-strategy: ant_path_matcher

【讨论】:

  • 有这方面的文档吗?
  • 这是做什么的?
  • 出于某种原因,在 springfox-swagger-ui 版本(3.0.0)和 spring-boot 版本(2.6.2)上对我不起作用。下降到 spring-boot 版本(2.5.8)并解决了我的 application.properties 中没有 spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER 的问题
  • @CoderCal 这个解决方案对我有用:github.com/springfox/springfox/issues/…
【解决方案2】:

我在使用 springfox-swagger2springfox-swagger-ui 时遇到了同样的问题 将 spring boot 版本从 2.6.0 切换回 2.5.2 解决了我的问题。

我知道回滚到旧版本并不是解决问题的最佳方法,但目前对我有所帮助。

【讨论】:

  • 它解决了我的问题 :) 谢谢
  • 它解决了我的问题。谢谢!
  • 是的,就是这样。这发生在我的 open-api-generator 集成中,它使用 springfox 进行实现。我什至尝试使用 Spring Boot 版本 2.6.2 将 springfox-swagger2 和 springfox-swagger-ui 更新到最新版本 3.0.x。没有运气。不得不回滚到 springfox 的 Spring boot 2.5.4 和 2.9.2 版本。希望将来他们能解决这个问题
  • spring boot 2.6.2 包含推荐的 log4j 2.17 所以这确实需要修复
【解决方案3】:

我在 spring boot 版本 1.5.3.RELEASE 中遇到了同样的问题,但可以通过添加 guava 版本 20.0 来解决。

    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>20.0</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.9.2</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.9.2</version>
    </dependency>

【讨论】:

    【解决方案4】:

    解决方法是回滚到 springfox-swagger2 2.5.0。

    【讨论】:

    • 对我来说,springfox-swagger2 的最新工作版本是 2.8.0,所以尝试回滚到那个版本。与最新发布的 springfox-swagger-ui 2.9.2 版本结合使用。
    • 文档工具如何杀死应用程序完全超出了我的理解。不负责任。
    • 非常感谢@MateŠimović 2.8.0 的东西对我有用 springfox-swagger-ui-2.9.2 和 spring-boot-starter-parent 2.6.2!!
    【解决方案5】:

    我遇到了类似的问题,在关注Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'后解决了

    我使用的是 spring 2.6.1 和 springfox-swagger2 2.9.2。 "在 application.properties 文件中将 spring.mvc.pathmatch.matching-strategy 设置为 ant-path-matcher"

    【讨论】:

    • 如果存在 spring boot 执行器依赖项,仅添加此项将不起作用。我必须删除执行器依赖项(当然会丢失执行器端点)。并且在使用高达 3.0.0 的 swagger 版本添加此属性后,此方法有效
    【解决方案6】:

    这个问题是由Spring Fox 3.0.0 不支持新的PathPattern Based Path Matching Strategy for Spring MVC 引起的,它现在是spring-boot 2.6.0 的新默认值。

    这个问题实际上有一些解决方法,例如:

    1. spring-boot 降级回低于 2.6.0 的版本。
    2. 在 yml 中将 PathPattern 匹配改回 AntPatternMatching,如 @santhanam 所述。
    3. SpringFox 已经有一年左右没有更新了,所以我宁愿将它从项目中完全删除,并用维护的 springdoc-openapi 库替换它。 springdoc 文档中有一个部分是关于从 SpringFox 迁移的,实际上执行起来非常简单。并且您将完全摆脱 SpringFox 引起的问题。

    【讨论】:

      【解决方案7】:

      对我来说,问题似乎是试图将参数传递给未得到解决的控制器操作(对于带有 RestController 注释的控制器)。

      例如

      @ResponseBody
      @PostMapping(value = "/foo")
      com.bestbuy.checkout.domain.Order foo(
          Bar justSomeObject
      ) {
      

      【讨论】:

        【解决方案8】:

        对于 Spring-Boot 2.6.0 和 SpringFox 3.0.0 的问题是 pathmatcher,您可以使用以下属性设置 pathmach,此问题将得到解决

          spring:
                mvc:
                  pathmatch:
                        matching-strategy: ant_path_matcher
        

        【讨论】:

          【解决方案9】:

          Spring-Boot 2.6.2 的问题是路径匹配器,您可以在 application.properties 文件中使用以下属性设置 pathmach,此问题将得到解决

          “spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER”

          【讨论】:

          • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
          【解决方案10】:

          我在我的 SwaggerConfig 中添加了 @EnableWebMvc 作为装饰器,这解决了问题。

          @EnableWebMvc
          public class SwaggerConfig {}
          

          版本:Sprint 2.6.1 和 springfox-swagger* 2.9.2

          【讨论】:

            【解决方案11】:

            将您的查询更改为

            @Modifying
            @Transactional
            @Query("from employee as ft where ft.company.id = :companyId")
            void deleteAllEmployeeCompany(
                    @Param("companyId") @RequestParam("companyId") int companyId);
            

            或使用 SpEL

            @Modifying
            @Transactional
            @Query("from employee as ft where ft.company.id = ?#{companyId}")
            void deleteAllEmployeeCompany(
                    @Param("companyId") @RequestParam("companyId") int companyId);
            

            查看https://spring.io/blog/2014/07/15/spel-support-in-spring-data-jpa-query-definitions

            【讨论】:

            • 我已经试过你的答案了。但它会导致同样的错误。
            • 我认为这个问题与spring-fox有关,而不是与spring-data有关。 documentationPluginsBootstrapper 是一个 spring-fox 组件。你用的是什么版本的spring-fox?
            • 我没有在我的应用程序中使用 spring-fox。
            • 请分享所有依赖的列表。
            【解决方案12】:

            根据:https://github.com/springfox/springfox/issues/2616 解决方案,我尝试将排除项添加到最近添加的生菜库中,现在工作正常。只有 springfox 番石榴依赖应该来。根据这个问题,以下内容将起作用:

            <dependency>
                <groupId>com.netflix.hystrix</groupId>
                <artifactId>hystrix-javanica</artifactId>
                <version>1.3.16</version>
                    <exclusions>
                        <exclusion>
                            <groupId>com.google.guava</groupId>
                            <artifactId>guava</artifactId>
                        </exclusion>
                    </exclusions>
            </dependency>
            

            【讨论】:

              【解决方案13】:

              我在 gradle 中也遇到过类似的问题。我通过从 springfox 子依赖项中删除所有番石榴依赖项来解决它:

              implementation('io.springfox:springfox-spi:2.9.2') {
                  exclude group: 'com.google.guava', module: 'guava'
              }
              
              implementation('io.springfox:springfox-schema:2.9.2') {
                  exclude group: 'com.google.guava', module: 'guava'
              }
              
              implementation('io.springfox:springfox-spring-web:2.9.2') {
                  exclude group: 'com.google.guava', module: 'guava'
              }
              

              并分别实现番石榴:

              implementation('com.google.guava:guava:28.1-jre')
              

              我的 spring-boot 版本:

              2.5.0-快照

              【讨论】:

                【解决方案14】:

                减少项目的版本对我有帮助。 最初,我使用的是 spring 2.6.0,但我移到了 2.5.2,它解决了这个问题。

                【讨论】:

                  【解决方案15】:

                  根据官方doc,在 yaml 中添加以下属性为我解决了这个问题。

                  springfox:
                    documentation:
                      auto-startup: false
                  

                  【讨论】:

                  • 这将解决应用程序启动问题,但 springfox 将停止工作;)。我认为唯一要做的就是等待springfox的补丁。
                  【解决方案16】:

                  删除旧的 swagger 依赖项和配置类。 使用新的 springdoc 依赖会有所帮助

                      <dependency>
                          <groupId>org.springdoc</groupId>
                          <artifactId>springdoc-openapi-ui</artifactId>
                          <version>1.6.4</version>
                      </dependency>
                  

                  【讨论】:

                    【解决方案17】:

                    将 Springboot 版本从 2.6.0 降级到 2.5.4 可以解决问题,前提是以下 swagger 版本

                        <dependency>
                            <groupId>io.springfox</groupId>
                            <artifactId>springfox-swagger2</artifactId>
                            <version>2.9.2</version>
                        </dependency>
                        <dependency>
                            <groupId>io.springfox</groupId>
                            <artifactId>springfox-swagger-ui</artifactId>
                            <version>2.9.2</version>
                        </dependency>
                    

                    【讨论】:

                      【解决方案18】:

                      我发现spring默认使用mvcmatchers,这与swagger冲突,因为它使用了antmatchers,所以我们可以通过

                      一个

                      更改 spring 以使用 antmatchers 并对其进行配置 在 application.properties 中

                      spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER
                      

                      B

                      在 spring 中启用 mvcmatchers 创建一个配置文件供 swagger 使用

                      1. 在任何你想要的地方为 swagger 的配置创建一个文件
                      2. 添加这些注释
                      @EnableWebMvc
                      @EnableSwagger2
                      @Component
                      public class SwaggersConfigs {
                      }
                      

                      C

                      在所有 Spring 应用程序中通过 put 启用 mvcmatchers @EnableWebMvc spring boot application主类上面的注解 像这样

                      
                      @EnableWebMvc
                      @EnableSwagger2
                      @SpringBootApplication
                      public class SwaggerDemoApplication {
                      
                          public static void main(String[] args) {
                              SpringApplication.run(SwaggerDemoApplication.class, args);
                          }
                      
                      }
                      

                      D

                      使用其他 cmets 中提到的旧版本

                      【讨论】:

                        猜你喜欢
                        • 2013-03-23
                        • 2016-01-30
                        • 2021-07-14
                        • 2019-06-30
                        • 2015-06-30
                        • 1970-01-01
                        • 2020-05-17
                        • 1970-01-01
                        相关资源
                        最近更新 更多