Carleslc / Simple-YAML

This Java API provides an easy-to-use way to store data and provide configurations using the YAML format.
https://carleslc.me/Simple-YAML
GNU General Public License v3.0
132 stars 38 forks source link

NoSuchMethodError when registering config #62

Closed Ajneb97 closed 2 years ago

Ajneb97 commented 2 years ago

I am trying to create a config file using the following method: YamlFile yamlFile = new YamlFile("config.yml");

but I get an error on that line, telling me that there is a missing method from snakeyml. I am using the latest version of Simple-YAML with maven, and Velocity.

imagen

Carleslc commented 2 years ago

Not a bug. You have a dependency clash with snakeyaml (required in both Simple-YAML and Velocity). Velocity uses an older version of snakeyaml than the required in Simple-YAML, and maven is selecting the older version probably because finds it first in the dependency tree. I don't know if you have the latest version of Velocity and if they have upgraded the snakeyaml to at least version 1.30.

Check issue #57 for help on how to solve the version clash.

Ajneb97 commented 2 years ago

I fixed it, but I had to add the snakeyaml 1.30 dependency manually to maven, because another error appeared. It seems Simple-YAML is not using the latest version. imagen

Carleslc commented 2 years ago

Simple-Yaml 1.8 uses snakeyaml 1.30, which is the latest version of snakeyaml. Velocity 3.1.1 uses snakeyaml 1.26. Adding the snakeyaml 1.30 dependency in your pom along with Simple-Yaml 1.8 should be enough to resolve the version conflict.

The new error seems the same problem anyway, due to the same version clash of snakeyaml. Both setIndentWithIndicator and setProcessComments methods were introduced in snakeyaml 1.28. If those methods are not found that means that maven is still selecting the wrong version.

I see you've done some relocation, maybe you have both versions around and still conflicting. Check it with mvn dependency:tree -Dverbose

Try the other options provided in the issue #57 (dependencyManagement and snakeyaml exclusion inside the Velocity dependency tag).

Ajneb97 commented 2 years ago

Thx it is fixed now.

Carleslc commented 2 years ago

What configuration did resolve the issue for you? Exclusion? Or was something related to relocation?

Ajneb97 commented 2 years ago

Relocation and I had to manually add snakeyaml 1.30 to maven `

org.yaml
        <artifactId>snakeyaml</artifactId>
        <version>1.30</version>

`