相关疑难解决方法(0)

Springfox 3.0.0 无法与 Spring Boot 2.6.0 一起使用

Springfox 3.0.0 无法与 Spring Boot 2.6.0 一起使用,升级后出现以下错误

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181)
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
    at java.base/java.lang.Iterable.forEach(Iterable.java:75)
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155)
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:935)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:586)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:302)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1290)
    at com.enkindle.AntivirusApplication.main(AntivirusApplication.java:16)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: java.lang.NullPointerException: Cannot invoke "org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.getPatterns()" because "this.condition" is null
    at springfox.documentation.spring.web.WebMvcPatternsRequestConditionWrapper.getPatterns(WebMvcPatternsRequestConditionWrapper.java:56)
    at springfox.documentation.RequestHandler.sortedPaths(RequestHandler.java:113)
    at …
Run Code Online (Sandbox Code Playgroud)

java swagger spring-boot springfox spring-boot-2.6.0

66
推荐指数
5
解决办法
10万
查看次数

添加了 Springfox Swagger-UI 但它不起作用,我错过了什么?

按照此处的说明操作:

http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api

我将这些依赖项添加到我的项目中:

compile "io.springfox:springfox-swagger2:2.7.0"
compile "io.springfox:springfox-swagger-ui:2.7.0"
Run Code Online (Sandbox Code Playgroud)

并像这样配置 SpringFox Swagger:

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }
}
Run Code Online (Sandbox Code Playgroud)

但是 Swagger UI 似乎没有启用。我试过:

我得到的只是:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon Sep 11 09:43:46 BST 2017
There was an …
Run Code Online (Sandbox Code Playgroud)

spring swagger swagger-ui spring-boot springfox

23
推荐指数
5
解决办法
4万
查看次数

Swagger 2 问题 - Spring Boot

我正在使用教程,一切都工作正常,直到我开始处理 swagger 2 依赖项。\n我现在想知道是否有办法解决这个问题。

\n

Swagger配置:

\n
package com.animes.apirest.config;\n\nimport springfox.documentation.swagger2.annotations.EnableSwagger2;\nimport org.springframework.context.annotation.Bean;\nimport org.springframework.context.annotation.Configuration;\n\nimport springfox.documentation.builders.RequestHandlerSelectors;\nimport springfox.documentation.service.ApiInfo;\nimport springfox.documentation.service.Contact;\nimport springfox.documentation.service.VendorExtension;\nimport springfox.documentation.spi.DocumentationType;\nimport springfox.documentation.spring.web.plugins.Docket;\n\n\nimport static springfox.documentation.builders.PathSelectors.regex;\n\nimport java.util.ArrayList;\n\n@Configuration\n@EnableSwagger2\npublic class SwaggerConfig {\n    \n    @Bean\n    public Docket atividadeApi() {\n        return new Docket(DocumentationType.SWAGGER_2)\n                .select()\n                .apis(RequestHandlerSelectors.basePackage("com.atividades.apirest"))\n                .paths(regex("/api.*"))\n                .build()\n                .apiInfo(metaInfo());\n    }\n\n    private ApiInfo metaInfo() {\n\n        ApiInfo apiInfo = new ApiInfo(\n                "Atividades API REST",\n                "API REST de cadastro de atividades.",\n                "1.0",\n                "Terms of Service",\n                new Contact("Jo\xc3\xa3o VR", "www.una.br/",\n                        " "),\n                "Apache License Version 2.0",\n                "https://www.apache.org/licesen.html", new ArrayList<VendorExtension>()\n        );\n\n        return apiInfo;\n    }\n}\n\n
Run Code Online (Sandbox Code Playgroud)\n

pom.xml: …

java spring jpa spring-boot

19
推荐指数
4
解决办法
8万
查看次数

无法使用 Spring Fox 启动 bean 'documentationPluginsBootstrapper' Spring boot Swagger 实现?

我在 Spring Boot 应用程序中使用 springfox-boot-starter 依赖项来获取 swagger UI,但是当我尝试运行该应用程序时,出现以下错误

    Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NoSuchMethodError: org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;)Ljava/util/Optional;
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:184)
        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:52)
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:157)
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:121)
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:885)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:161)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
Run Code Online (Sandbox Code Playgroud)

我的配置文件:


 @Bean
 public Docket productApi() {
        
     return new Docket(DocumentationType.SWAGGER_2)
        .select()
        .apis(RequestHandlerSelectors.basePackage("com.swagger.demo.controller"))
        .paths(regex("/student.*"))
        .build()
        .enableUrlTemplating(true)
        .produces(DEFAULT_PRODUCES_AND_CONSUMES)
        .consumes(DEFAULT_PRODUCES_AND_CONSUMES)
        .apiInfo(apiEndPointsInfo());
    }

private ApiInfo apiEndPointsInfo() {

    return new ApiInfoBuilder()
            .title("demo")
            .description("demo")
            .version("1.0")
            .build();
} 

Run Code Online (Sandbox Code Playgroud)

以下是我正在使用的依赖项。 pom.xml 文件:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from …
Run Code Online (Sandbox Code Playgroud)

swagger spring-boot springfox

10
推荐指数
1
解决办法
3万
查看次数

将 Spring Boot 升级到 2.7.0 - 无法启动 bean 'documentationPluginsBootstrapper

升级Springboot版本- 2.7.0 ext { springBootVersion = '2.7.0' wsdl2javaVersion='0.10' cxfVersion='3.4.3' }

云版本: ext { set('springCloudVersion', '2021.0.3') }

Springfox: //swagger 编译“io.springfox:springfox-swagger2:2.9.2” 编译“io.springfox:springfox-swagger-ui:2.9.2”

出现错误:org.springframework.context.ApplicationContextException:无法启动 bean 'documentationPluginsBootstrapper';嵌套异常是java.lang.NullPointerExceptionclass

任何领导都非常感谢解决这个问题。

java spring-boot

8
推荐指数
2
解决办法
2万
查看次数

Swagger 2 问题 spring Boot

我在 Spring Boot 中面临 Swagger 集成问题。查看代码和错误片段。

------------------POM--------------------

<properties>
    <java.version>1.8</java.version>
    <swagger.version>2.9.2</swagger.version>
</properties>

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>${swagger.version}</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>${swagger.version}</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-bean-validators</artifactId>
    <version>${swagger.version}</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)

-----------------应用类--------------

@SpringBootApplication
@EnableSwagger2
public class ProducerApplication {

  public static void main(String[] args) {
    SpringApplication.run(ServletPocProducerApplication.class, args);
  }
  
  @Bean 
  public Docket api() { 
    return new Docket(DocumentationType.SWAGGER_2)
      .select() 
      .apis(RequestHandlerSelectors.any())
      .paths(PathSelectors.any())
      .build();
  }
}
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪

org.springframework.context.ApplicationContextException: Failed to start bean 
'documentationPluginsBootstrapper'; nested exception is 
 java.lang.NullPointerException: Cannot invoke 
"org.springframework.web.servlet.mvc.condition.PatternsRequestCondition.toString()" 
because the return value of 
"springfox.documentation.spi.service.contexts.Orderings.patternsCondition(springfox.docume 
ntation.RequestHandler)" is null
   at …
Run Code Online (Sandbox Code Playgroud)

java swagger-ui spring-boot swagger-2.0

7
推荐指数
3
解决办法
2万
查看次数

无法在春季数据休息中启动 bean 'documentationPluginsBootstrapper'

我正在为我的应用程序使用 spring 数据休息。

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

方法:-

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

错误:-

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]
Run Code Online (Sandbox Code Playgroud)

如何解决这个问题?

更新:-

所有依赖项的列表:-

[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] |  | …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc spring-data springfox

4
推荐指数
13
解决办法
2万
查看次数

Spring Boot 不使用配置的 Jackson ObjectMapper 和 @EnableWebMvc

我想ObjectMapper在我的项目中使用 Jackson 的配置版本(忽略空值和 snake_case,也使用一些自定义模块)。

在我的大型项目中,我无法让 Spring MVC 实际使用这个映射器。

build.gradle:

buildscript {
  ext {
    springBootVersion = '1.5.6.RELEASE'
  }
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
  }
}

apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
  mavenCentral()
}

dependencies {
  compile('org.springframework.boot:spring-boot-starter')
  compile("org.springframework.boot:spring-boot-starter-jetty:${springBootVersion}")
  compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}")

  compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.8'
  compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.8'

  testCompile('org.springframework.boot:spring-boot-starter-test')
}
Run Code Online (Sandbox Code Playgroud)

我的应用程序.yml:

spring:
  application:
  name: Jackson test
jackson:
  property-naming-strategy: SNAKE_CASE
  default-property-inclusion: non_empty
debug: …
Run Code Online (Sandbox Code Playgroud)

spring-mvc jackson spring-boot

2
推荐指数
1
解决办法
1649
查看次数