scala 获取java.lang.NoSuchMethodError:org.yaml.snakeyaml.constructor.SafeConstructor:方法< init>()在使用SBT运行Play应用程序时未找到V

2g32fytz  于 2023-04-12  发布在  Scala
关注(0)|答案(1)|浏览(2247)

java.lang.NoSuchMethodError: org.yaml.snakeyaml.constructor.SafeConstructor: method ()V not found at io.swagger.v3.parser.util.DeserializationUtils$CustomSnakeYamlConstructor.(DeserializationUtils.java:397) at io.swagger.v3.parser.util.DeserializationUtils.readYamlTree(DeserializationUtils.java:209) at io.swagger.v3.parser.util.DeserializationUtils.deserializeIntoTree(DeserializationUtils.java:145) at io.swagger.v3.parser.OpenAPIV3Parser.readContents(OpenAPIV3Parser.java:168) at io.swagger.v3.parser.OpenAPIV3Parser.readLocation(OpenAPIV3Parser.java:97) at io.swagger.parser.OpenAPIParser.readLocation(OpenAPIParser.java:16) at com.atlassian.oai.validator.util.OpenApiLoader.readSwaggerParserResult(OpenApiLoader.java:79) at com.atlassian.oai.validator.util.OpenApiLoader.loadApi(OpenApiLoader.java:48) at com.atlassian.oai.validator.OpenApiInteractionValidator$Builder.build(OpenApiInteractionValidator.java:643)
This is coming after updating the version of snakeyaml from 1.3 to 2.0

42fyovps

42fyovps1#

实际上,snakeyaml 2.0没有为org.yaml.snakeyaml.constructor.SafeConstructor类提供empty-arg构造函数。
在snakeyaml 1.33中存在这样的构造函数,但已被弃用。
在snakeyaml2.0中尝试替换

import org.yaml.snakeyaml.{LoaderOptions, Yaml}
import org.yaml.snakeyaml.constructor.SafeConstructor

val safeConstructor = new SafeConstructor
val yaml = new Yaml(safeConstructor)

val loaderOptions = new LoaderOptions
// loaderOptions.setCodePointLimit(...)
// ...
val safeConstructor = new SafeConstructor(loaderOptions)
val yaml = new Yaml(safeConstructor)

https://bitbucket.org/snakeyaml/snakeyaml/wiki/Documentation#markdown-header-loading-yaml
https://bitbucket.org/snakeyaml/snakeyaml/src/master/src/test/java/examples/SafeConstructorExampleTest.java

相关问题