Openapitools在从springboot 2.x更新到springboot 3.1.0后不再起作用。

huangapple go评论66阅读模式
英文:

Openapitools does not work anymore after update from springboot 2.x to springboot 3.1.0

问题

当执行 gradle 任务 openApiGenerate 时,会出现以下错误:

Caused by: java.lang.NoSuchMethodError: 'com.fasterxml.jackson.core.io.ContentReference com.fasterxml.jackson.dataformat.yaml.YAMLFactory._createContentReference(java.lang.Object)'
at com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createGenerator(YAMLFactory.java:479)
at com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createGenerator(YAMLFactory.java:15)
at com.fasterxml.jackson.databind.ObjectMapper.createGenerator(ObjectMapper.java:1164)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3742)
at org.openapitools.codegen.serializer.SerializerUtils.toYamlString(SerializerUtils.java:38)
at org.openapitools.codegen.DefaultCodegen.generateYAMLSpecFile(DefaultCodegen.java:7094)
at org.openapitools.codegen.languages.JavaClientCodegen.postProcessSupportingFileData(JavaClientCodegen.java:1129)
at org.openapitools.codegen.DefaultGenerator.buildSupportFileBundle(DefaultGenerator.java:814)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:917)

我尝试降级 jackson,但仍然出现相同的错误(尽管依赖树显示使用了旧版本)。

该任务定义如下:

openApiGenerate {
    generatorName = "java"
    inputSpec = "$projectDir/$openApiDir"
    outputDir = "$buildDir"
    library = "template"
    apiPackage = "myapi.api"
    modelPackage = "mymodel.model"
    invokerPackage = "myinvoker.invoker"
    generateModelTests = false
    generateApiTests = false
    generateApiDocumentation = false
    generateModelDocumentation = false
    configOptions = [
            useSpringBoot3: "true",
            sourceFolder: "$generatedBaseDir",
    ]
}

有一些建议如何修复这个错误?

英文:

When the gradle task openApiGenerate is executed the following error occurs:

Caused by: java.lang.NoSuchMethodError: 'com.fasterxml.jackson.core.io.ContentReference com.fasterxml.jackson.dataformat.yaml.YAMLFactory._createContentReference(java.lang.Object)'
at com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createGenerator(YAMLFactory.java:479)
at com.fasterxml.jackson.dataformat.yaml.YAMLFactory.createGenerator(YAMLFactory.java:15)
at com.fasterxml.jackson.databind.ObjectMapper.createGenerator(ObjectMapper.java:1164)
at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3742)
at org.openapitools.codegen.serializer.SerializerUtils.toYamlString(SerializerUtils.java:38)
at org.openapitools.codegen.DefaultCodegen.generateYAMLSpecFile(DefaultCodegen.java:7094)
at org.openapitools.codegen.languages.JavaClientCodegen.postProcessSupportingFileData(JavaClientCodegen.java:1129)
at org.openapitools.codegen.DefaultGenerator.buildSupportFileBundle(DefaultGenerator.java:814)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:917)

I tried to downgrade jackson but still the same error (although dependency tree says that the older version is used).

The task is defined like this:

openApiGenerate {
    generatorName = "java"
    inputSpec = "$projectDir/$openApiDir"
    outputDir = "$buildDir"
    library = "template"
    apiPackage = "myapi.api"
    modelPackage = "mymodel.model"
    invokerPackage = "myinvoker.invoker"
    generateModelTests = false
    generateApiTests = false
    generateApiDocumentation = false
    generateModelDocumentation = false
    configOptions = [
            useSpringBoot3: "true",
            sourceFolder: "$generatedBaseDir",
    ]
}

Some hints how to fix the error?

答案1

得分: 0

Error occurs only if an other plugin is imported that uses a newer version of com.fasterxml.jackson.core.*

英文:

Error occurs only if an other plugin is imported that uses a newer version of com.fasterxml.jackson.core.*

huangapple
  • 本文由 发表于 2023年7月6日 20:50:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/76629033.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定