在spring data rest中,无法启动bean 'documentationPluginsBootstrapper'。

10 浏览
0 Comments

在spring data rest中,无法启动bean 'documentationPluginsBootstrapper'。

我正在使用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

0
0 Comments

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

解决这个问题的方法是在application.properties或application.yml中添加pathmatcher配置。

对于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。

这个解决方法对我有效:github.com/springfox/springfox/issues/…

在使用spring boot 2.6.3时对我有效。

如果你使用了spring actuator,这个方法将不起作用。

这个方法对我也有效,我升级到了spring boot 2.6。

我尝试了多种解决方法,但最终通过以上方法解决了问题,我的spring版本是2.6.4,我还使用了spring actuator springfox-swagger2 - 3.0.0 springfox-boot-starter - 3.0.0 springfox-swagger-ui - 3.0.0。

这个方法对我在spring版本2.6.7和所有springfox依赖版本3.0.0上有效。

在我使用的swagger版本:'2.6.0'上解决了这个问题。

对我解决了问题(springfox-swagger2版本3.0.0和spring-boot版本2.7.4)。

只有更改application.properties对我有效。

0
0 Comments

在使用Spring Data Rest时出现了"Failed to start bean 'documentationPluginsBootstrapper'"的错误。出现这个错误的原因是因为Spring默认使用了mvcmatchers,而Swagger使用了antmatchers,导致冲突。解决这个问题的方法有以下几种:

A. 修改Spring使用antmatchers:

在application.properties文件中添加以下配置:

spring.mvc.pathmatch.matching-strategy = ANT_PATH_MATCHER

B. 在Spring中启用mvcmatchers,并为Swagger创建一个配置文件:

1. 在任意位置创建一个Swagger配置文件,命名为SwaggersConfigs。

2. 在该文件中添加以下注解:

public class SwaggersConfigs {
}

C. 在Spring应用程序的主类上启用mvcmatchers:

在Spring Boot应用程序的主类上添加以下注解:

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

D. 使用其他版本的Spring和Swagger。

以上解决方法中,D选项由一位“传奇”提供。

通过以上方法,可以解决"Failed to start bean 'documentationPluginsBootstrapper'"错误。

0
0 Comments

这个问题的出现原因是由于Spring Fox 3.0.0不支持Spring MVC的新默认路径匹配策略PathPattern Based Path Matching Strategy,这个新策略是从spring-boot 2.6.0开始的。解决方法有以下几种:

1. 将spring-boot版本降级到2.6.0以下。不推荐这种方法,因为旧版本的spring boot / spring framework存在严重的安全问题。

2. 在yml文件中将PathPattern匹配改回AntPatternMatching。可以参考上述链接中提到的方法。

3. 推荐将项目中的SpringFox完全移除,并替换为维护良好的springdoc-openapi库。springdoc的文档中有关于从SpringFox迁移的说明,迁移过程非常简单,而且可以完全摆脱SpringFox引起的问题。

个人认为第三种方法是最好的解决方案。依赖一个几乎两年没有更新的项目是不明智的选择。截至目前,SpringFox自2020年10月以来没有进行任何提交。

降级spring-boot可能会导致旧版本的log4j存在严重的JNDI调用漏洞,请小心使用。

每当我看到"降级"这个词,我都感到不安。

0