从 toml 文件读取 java

Read from toml file java

我正在使用带有 java 的 toml,第一个 time.I 配置了 pom.xml 依赖项,我想从 .toml 文件中读取。

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

我收到这个错误:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/Gson

Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson

在code.I这一行给我这个错误想问我如何使用.read()方法

读取java中的toml文件

谢谢

问题是你在maven中添加了toml依赖,但没有添加com.google.gson,所以错误不是.read方法。 添加 com.google.gson 依赖项,它起作用了!