idea运行程序的时候,出现Error: A JNI error has occurred, please check your installation and try again这个错误的话,抛出异常:
java.lang.NoClassDefFoundError: org/springframework/web/socket/server/standard/ServerEndpointExporter at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) at java.lang.Class.privateGetMethodRecursive(Class.java:3048) at java.lang.Class.getMethod0(Class.java:3018) at java.lang.Class.getMethod(Class.java:1784) at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526) Caused by: java.lang.ClassNotFoundException: org.springframework.web.socket.server.standard.ServerEndpointExporter at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 7 more Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" Process finished with exit code 1
即各种类找不到,出现这种错误的原因实际上就是pom文件中依赖的包在运行的时候没有被导入,此时对应导入的依赖的scope的标签值为provided,而在idea中如果不进行设置的话,idea默认是不加载provided的依赖的,因此需要在idea中进行设置,使idea能够加载该类型的依赖,设置的方式如下,即将红色圆圈中的选项勾上就可以解决问题了!
参考https://www.syrr.cn/news/21139.html?action=onClick
标签:lang,again,Exception,java,idea,try,报错,JNI,Class From: https://www.cnblogs.com/guoxinying/p/17662126.html