[英]Read from toml file java
I am using toml with java for the first time.I configured the pom.xml dependencies and i want to read from the .toml file. 我第一次在Java中使用toml。我配置了pom.xml依赖项,我想从.toml文件中读取。
Toml toml = new Toml().read(new FileInputStream("/home/abdallah/Desktop/config.toml"))
Toml toml =新Toml()。read(新FileInputStream(“ / home / abdallah / Desktop / config.toml”))
I am getting this error: 我收到此错误:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/Gson
线程“主”中的异常java.lang.NoClassDefFoundError:com / google / gson / Gson
Caused by: java.lang.ClassNotFoundException: com.google.gson.Gson
造成原因:java.lang.ClassNotFoundException:com.google.gson.Gson
It is giving me this error in this line of code.I want to ask how can i read the toml file in java using the .read() method 它在这行代码中给了我这个错误。我想问一下如何使用.read()方法读取Java中的toml文件
thank you 谢谢
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. 问题是您在maven中添加了toml依赖项,但没有添加com.google.gson,因此错误不是.read方法。 Add com.google.gson dependency and it works!
添加com.google.gson依赖关系,它可以工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.