Reputation: 173
SnakeYaml jar present at classPath: snakeyaml-1.26.jar
2330 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.yaml.snakeyaml.Yaml.<init>(Lorg/yaml/snakeyaml/constructor/BaseConstructor;Lorg/yaml/snakeyaml/representer/Representer;Lorg/yaml/snakeyaml/DumperOptions;Lorg/yaml/snakeyaml/LoaderOptions;Lorg/yaml/snakeyaml/resolver/Resolver;)V
at org.springframework.boot.env.OriginTrackedYamlLoader.createYaml(OriginTrackedYamlLoader.java:71)
at org.springframework.beans.factory.config.YamlProcessor.process(YamlProcessor.java:162)
at org.springframework.boot.env.OriginTrackedYamlLoader.load(OriginTrackedYamlLoader.java:76)
at org.springframework.boot.env.YamlPropertySourceLoader.load(YamlPropertySourceLoader.java:50)
at org.springframework.boot.context.config.ConfigFileApplicationListener$Loader.loadDocuments(ConfigFileApplicationListener.java:607)
Upvotes: 15
Views: 67481
Reputation: 4147
In the case of Micronaut, it's solved using the version 3.8.7, which comes with snakeyaml 2.0 support. See -> https://micronaut.io/2023/03/09/micronaut-framework-3-8-7-released/
Upvotes: 0
Reputation: 589
Keeping jackson at 2.15.2 and snakeyaml at 1.33 resolved issue for me.
Upvotes: 0
Reputation: 85
Please upgrade to 2.7.10 if you are using JDK 11 and no plan to upgrade to springboot 3.x having dependency on JDK 17.
Root cause of the issue is mentioned and fixed here
Other solution is to move to application.properties instead of application.yml, so that you will not encounter this issue.
Upvotes: 4
Reputation: 1396
I received this error when I updated snakeyaml from 1.33 to 2.0. You need to downgrade version to 1.33
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.33</version>
</dependency>
link to mvn repo : https://mvnrepository.com/artifact/org.yaml/snakeyaml
Upvotes: 4
Reputation: 3035
I had a similar problem and my solution was to use snakeyaml in the exact same version as spring boot does.
In general a good trick is to import maven dependencies from org.springframework.boot:spring-boot-dependencies
in order to avoid version incompatibilities.
If you're using mvn
, add this under <dependencyManagement>
in your pom:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
and then this under <dependencies>
:
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<scope>runtime</scope>
</dependency>
For example spring-boot-dependencies-2.3.6.RELEASE.pom uses snakeyaml in 1.26:
<snakeyaml.version>1.26</snakeyaml.version>
Whereas spring-boot-dependencies-2.5.12.pom uses 1.28:
<snakeyaml.version>1.28</snakeyaml.version>
And spring-boot-dependencies-2.6.1.pom uses 1.29:
<snakeyaml.version>1.29</snakeyaml.version>
Hope this helps.
Upvotes: 5