首页 > 代码库 > Java中的List转换成JSON报错(三)

Java中的List转换成JSON报错(三)

1、错误描述

Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher
	at net.sf.json.util.CycleDetectionStrategy.<clinit>(CycleDetectionStrategy.java:37)
	at net.sf.json.JsonConfig.<clinit>(JsonConfig.java:65)
	at net.sf.json.JSONArray.fromObject(JSONArray.java:105)
	at com.you.model.ListToJSON.main(ListToJSON.java:29)
Caused by: java.lang.ClassNotFoundException: net.sf.ezmorph.Morpher
	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
	... 4 more

2、错误原因

  从“Caused by: java.lang.ClassNotFoundException: net.sf.ezmorph.Morpher”这句可以看出,是缺少jar


3、解决办法

   将“ezmorph-1.0.6.jar”复制到lib目录下

Java中的List转换成JSON报错(三)