Exception in thread "main" java.lang.NoClassDefFoundError: org/json4s/Formats
编译的时候没有问题,但是本地做测试时运行不了。
首先,看看org/json4s/Formats是什么包引进来的,mac版idea可以双击shift,看到是json4s-core_2.11包里的类
用dependence analyzer插件看看json4s-core_2.11依赖的信息,发现是provided类型的依赖,(provided编译,测试阶段jar包都在classpath中,运行没有,所以本地运行的时候会找不到jar包中相关的类)。
想要本地测试可以正常跑起来,可以把依赖的scope标签换成compile类型(编译,测试,运行阶段jar包都在classpath中),如果不想改的话,也可以设置idea运行的配置,如图所示