Search code examples
javayamlsnakeyaml

How to resolve snakeyaml NoSuchMethodError: getStyle()


In my spring boot application, I am using snakeyaml to parse a YAML file. I get the following error though when using the library:

java.lang.NoSuchMethodError: org.yaml.snakeyaml.nodes.ScalarNode.getStyle()Ljava/lang/Character;

I am using the following maven dependency:

<dependency>
  <groupId>org.yaml</groupId>
  <artifactId>snakeyaml</artifactId>
  <version>1.21</version>
</dependency>

Does anyone have a hint for resolving this error?

Edit:

The error seems to occur when parsing spring's application.yml:

server:
  port: 8084

Solution

  • That is due to this change:

    Refactor ScalarNode - use enum ScalarStyle instead of Character

    You can either roll back to SnakeYaml 1.19, which is the last release before this change, or wait for Spring Boot to support SnakeYaml 1.20+.