简体   繁体   English

找不到接口 org.springframework.web.server.ServerWebExchange 的主要或默认构造函数

[英]No primary or default constructor found for interface org.springframework.web.server.ServerWebExchange

I have added swagger support to a microservice written in spring-boot.我已经为用 spring-boot 编写的微服务添加了 swagger 支持。 I am getting below error我得到以下错误

HTTP ERROR 500 org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: No primary or default constructor found for interface org.springframework.web.server.ServerWebExchange

URI:    /docs/swagger-ui.html
STATUS: 500
MESSAGE:    org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: No primary or default constructor found for interface org.springframework.web.server.ServerWebExchange
SERVLET:    dispatcherServlet
CAUSED BY:  org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalStateException: No primary or default constructor found for interface org.springframework.web.server.ServerWebExchange
CAUSED BY:  java.lang.IllegalStateException: No primary or default constructor found for interface org.springframework.web.server.ServerWebExchange
CAUSED BY:  java.lang.NoSuchMethodException: org.springframework.web.server.ServerWebExchange.<init>()

and here is the gradle file of my project!这是我项目的 gradle 文件!

plugins {
  id 'java-library'
  id 'idea'
  id 'io.franzbecker.gradle-lombok' version '4.0.0'
  id 'jacoco'
  id 'org.sonarqube' version '3.0'
  id 'com.github.spacialcircumstances.gradle-cucumber-reporting' version '0.1.22'
  id 'com.gorylenko.gradle-git-properties' version '2.0.0'
  id "org.springframework.boot"
  id "com.github.johnrengelman.processes" version "0.5.0"
  id "org.springdoc.openapi-gradle-plugin" version "1.3.2"
}

archivesBaseName = 'gates-compnaygate'
sourceCompatibility = 11
targetCompatibility = 11
apply from: "$gradleDir/sonar.gradle"
apply from: "$gradleDir/docker.gradle"
apply from: "$gradleDir/jacoco.gradle"
apply from: "$gradleDir/integration-test.gradle"

apply from: "../gradle/contracts.gradle"

dockerPlugin {
  applicationName = archivesBaseName
}

bootJar {
  archiveFileName = "${archivesBaseName}.jar"
}

contracts {
  basePackageForTests = "${group}.gates.compnaygate.contracts"
  testFramework = 'JUNIT5'
  testMode = 'EXPLICIT'
  baseClassMappings {
    baseClassMapping(".*rest.*", "${group}.gates.compnaygate.contract.RestBase")
    baseClassMapping(".*messaging.*", "${group}.gates.compnaygate.contract.MessagingBase")
  }
}

test {
  useJUnitPlatform {
    excludeTags 'integration', 'component'
  }
}

repositories {
  mavenLocal()
  maven {
    url = 'https://nexus.company-conv.com/repository/conv-deps/'
  }
}

componentTest {
  doFirst {
    systemProperty 'contractTestRepositoryRoot', "$nexusRepositoryUrl/contract-releases/,$nexusRepositoryUrl/contract-snapshots/"
  }
}

dependencyManagement {
  imports {
    mavenBom 'org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR8'
  }
}

dependencies {

  configurations {
    // exclude Tomcat use Netty instead
    compile.exclude module: 'spring-boot-starter-tomcat'
    compile.exclude module: 'spring-webmvc'
    compile.exclude module: 'spring-boot-starter-web'
  }

  implementation('org.springdoc:springdoc-openapi-ui:1.5.9')
  implementation('org.springdoc:springdoc-openapi-webmvc-core:1.5.9')
  implementation('com.company.conv:common-web:0.8.0'){
    exclude group: 'org.springframework', module: 'spring-webmvc'
    exclude group: 'org.springframework.boot', module: 'spring-boot-starter-web'
  }

  implementation(
    'com.company.conv:common-log:0.1.8',
    'com.github.ben-manes.caffeine:caffeine',
    'com.github.jknack:handlebars:4.1.2',
    'org.apache.commons:commons-collections4:4.3',
    'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client',
    'org.springframework.cloud:spring-cloud-starter-stream-kafka',
    'org.springframework.cloud:spring-cloud-starter-aws',
    'org.springframework.cloud:spring-cloud-aws-core',
    'org.springframework.cloud:spring-cloud-aws-autoconfigure',
    'org.springframework.boot:spring-boot-starter-actuator',
    'org.springframework.boot:spring-boot-starter-webflux',
    'org.springframework.boot:spring-boot-starter-jetty',
    'org.springframework.cloud:spring-cloud-starter-openfeign',
    'org.springframework.boot:spring-boot-starter-cache',
    'org.springframework.boot:spring-boot-starter-data-jpa',
    'org.springframework.boot:spring-boot-starter-batch',
    'org.springframework.boot:spring-boot-starter-jdbc',
    'io.micrometer:micrometer-registry-statsd',
    'ch.qos.logback.contrib:logback-json-classic:0.1.5',
    'ch.qos.logback.contrib:logback-jackson:0.1.5',
  )
  implementation('org.mapstruct:mapstruct:1.4.2.Final')
  annotationProcessor('org.mapstruct:mapstruct-processor:1.4.2.Final')

  runtimeOnly(
    'org.postgresql:postgresql:42.2.2',
    'org.liquibase:liquibase-core',
  )

  testImplementation(
    'com.fasterxml.jackson.module:jackson-module-jaxb-annotations',
    'com.google.guava:guava-testlib',
    'com.opentable.components:otj-pg-embedded:0.13.1',
    /*'io.rest-assured:spring-web-test-client:4.1.2',*/
    'org.awaitility:awaitility:3.1.6',
    'org.springframework.boot:spring-boot-starter-test',
    'org.springframework.batch:spring-batch-test',
    /*'org.springframework.cloud:spring-cloud-starter-contract-verifier',*/
    'org.springframework.cloud:spring-cloud-stream-test-support'
  )
  testImplementation('org.springframework.cloud:spring-cloud-starter-contract-stub-runner') {
    exclude group: 'org.springframework.boot', module: 'spring-boot-starter-web'
  }
  testImplementation('org.springframework.cloud:spring-cloud-starter-contract-verifier') {
    exclude group: 'org.springframework', module: 'spring-webmvc'
  }
  testImplementation('io.rest-assured:spring-web-test-client:4.1.2') {
    exclude group: 'org.springframework', module: 'spring-webmvc'
  }
  testImplementation('io.findify:s3mock_2.12:0.2.4')
  testImplementation("com.company.conv:common-component-test:${componentTestVersion}")
}

// force to run sonarqube also after integration test to publish coverage report
project.tasks["sonarqube"].dependsOn test
openApi {
  apiDocsUrl.set("http://localhost:9898/v3/api-docs")
  outputDir.set(file("$buildDir/docs"))
  outputFileName.set("swagger.json")
  waitTimeInSeconds.set(90)
}

it has started working by replacing the implementation of open-api from webmvc to web-flux它已经开始工作,将 open-api 的实现从 webmvc 替换为 web-flux

implementation('org.springdoc:springdoc-openapi-webflux-ui:1.5.11')
implementation('org.springdoc:springdoc-openapi-webflux-core:1.5.11')

when accessing the swagger-ui.html in console of browser I am getting this error在浏览器的控制台中访问 swagger-ui.html 时出现此错误

{"path":"/docs/v3/api-docs","error":"Internal Server Error","message":"Duplicate key class Parameter {\n    name: api-version\n    in: header\n    description: null\n    required: null\n    deprecated: null\n    allowEmptyValue: null\n    style: null\n    explode: null\n    allowReserved: null\n    schema: class StringSchema {\n        class Schema {\n            type: string\n            format: null\n            $ref: null\n            description: null\n            title: null\n            multipleOf: null\n            maximum: null\n            exclusiveMaximum: null\n            minimum: null\n            exclusiveMinimum: null\n            maxLength: null\n            minLength: null\n            pattern: null\n            maxItems: null\n            minItems: null\n            uniqueItems: null\n            maxProperties: null\n            minProperties: null\n            required: null\n            not: null\n            properties: null\n            additionalProperties: null\n            nullable: null\n            readOnly: null\n            writeOnly: null\n            example: null\n            externalDocs: null\n            deprecated: null\n            discriminator: null\n            xml: null\n        }\n    }\n    examples: null\n    example: null\n    content: null\n    $ref: null\n}","timestamp":"Thu Nov 04 23:33:47 PKT 2021","status":500}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 找不到接口 org.springframework.data.jpa.domain.Specification] 的主要或默认构造函数,其根本原因 - No primary or default constructor found for interface org.springframework.data.jpa.domain.Specification] with root cause 找不到接口 org.springframework.data.domain.Pageable 的主要或默认构造函数 - No primary or default constructor found for interface org.springframework.data.domain.Pageable mongodb org.springframework.data.authentication.UserCredentials未找到默认构造函数 - mongodb org.springframework.data.authentication.UserCredentials No default constructor found org.springframework.beans.factory.BeanCreationException和org.springframework.beans.BeanInstantiationException,未找到默认构造函数 - org.springframework.beans.factory.BeanCreationException & org.springframework.beans.BeanInstantiationException,No default constructor found 没有找到接口 javax.ws.rs.core.UriInfo 的主要或单个公共构造函数 - 也没有找到默认构造函数 - No primary or single public constructor found for interface javax.ws.rs.core.UriInfo - and no default constructor found either 找不到默认的构造函数; 嵌套异常org.springframework.test.context.TestContext。 <init> () - No default constructor found; nested exception org.springframework.test.context.TestContext.<init>() ... 中构造函数的参数 0 需要一个无法找到的“org.springframework.web.client.RestTemplate”类型的 bean - Parameter 0 of constructor in ... required a bean of type 'org.springframework.web.client.RestTemplate' that could not be found 找不到org.springframework.web.WebApplicationInitializer - org.springframework.web.WebApplicationInitializer not found 找不到org.springframework.web.servlet.DispatcherServlet - org.springframework.web.servlet.DispatcherServlet Not Found 错误 找不到接口 javax.ws.rs.core.SecurityContext 的主要或默认构造函数 - Error No primary or default constructor found for interface javax.ws.rs.core.SecurityContext
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM