user2035039
user2035039

Reputation: 971

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

Upvotes: 9

Views: 14163

Answers (2)

Leonard Br&#252;nings
Leonard Br&#252;nings

Reputation: 13222

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>

Upvotes: 17

flyx
flyx

Reputation: 39638

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+.

Upvotes: 6

Related Questions