1

我第一次使用 toml 和 java。我配置了 pom.xml 依赖项,我想从 .toml 文件中读取。

Toml toml = new Toml().read(new FileInputStream("/home/abdallah/Desktop/config.toml"))

我收到此错误:

线程“主”java.lang.NoClassDefFoundError 中的异常:com/google/gson/Gson

引起:java.lang.ClassNotFoundException:com.google.gson.Gson

它在这行代码中给了我这个错误。我想问我如何使用 .read() 方法读取 java 中的 toml 文件

谢谢你

4

1 回答 1

4

The problem is that you added toml dependency in maven , but you didn't add com.google.gson , and thus the error is not the .read method. Add com.google.gson dependency and it works!

于 2016-12-14T14:34:38.373 回答