How to resolve snakeyaml NoSuchMethodError: getStyle()

user2035039 picture user2035039 · Jun 13, 2018 · Viewed 8.4k times · Source

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

Answer

Leonard Br&#252;nings picture Leonard Brünings · Sep 27, 2018

You need to update to SnakeYml 1.23, they fixed the incompatible API change introduced in 1.20.

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