Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject
at com.jz.core.common.baidu.AiBaiduUtil.getAuth(AiBaiduUtil.java:85)
at com.jz.core.common.baidu.AiBaiduUtil.getAuth_UNIT(AiBaiduUtil.java:25)
at com.jz.unit.utils.tools.DialogueUtil.utterance(DialogueUtil.java:30)
at com.jz.unit.utils.tools.DialogueUtil.main(DialogueUtil.java:39)
Caused by: java.lang.ClassNotFoundException: org.json.JSONObject
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 4 more
报错原因:少Java包。
解决办法:
引入依赖:
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
</dependency>
maven管理用的是:
https://blog.csdn.net/liurui50/article/details/99847472