linux启动jar包时,找不到报错
[root@ebs-141185 xl-admin]# java -Djava.library.path=/home/kabangke/xl-admin/lib -jar /home/kabangke/xl-admin/xl-admin.jarException in thread "main" java.lang.NoClassDefFoundError: org/springframework/web/servlet/config/annotation/WebMvcConfigurerAdapterat java.lang.ClassLoader.defineClass1(Native Method)at java.lang.ClassLoader.defineClass(ClassLoader.java:763)at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)at java.net.URLClassLoader.access$100(URLClassLoader.java:73)at java.net.URLClassLoader$1.run(URLClassLoader.java:368)at java.net.URLClassLoader$1.run(URLClassLoader.java:362)at java.security.AccessController.doPrivileged(Native Method)at java.net.URLClassLoader.findClass(URLClassLoader.java:361)at java.lang.ClassLoader.loadClass(ClassLoader.java:424)at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)at java.lang.ClassLoader.loadClass(ClassLoader.java:357)at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46)at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)at org.springframework.boot.loader.Launcher.launch(Launcher.java:50)at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:587)Caused by: java.lang.ClassNotFoundException: org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapterat java.net.URLClassLoader.findClass(URLClassLoader.java:381)at java.lang.ClassLoader.loadClass(ClassLoader.java:424)at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:94)at java.lang.ClassLoader.loadClass(ClassLoader.java:357)... 16 more
用的maven分离jar打包,没有指定lib目录
加上-Dloader.path=”lib/” 即可
nohup java -Dloader.path=”lib/” -jar xl-agent.jar > /dev/null 2>&1 &
linux启动jar包参考:全网最全Linux 运行jar包的几种方式_liunx 运行jar包_油焖茄子的博客-CSDN博客
maven打包jar包分离参考:springboot 从jar包中分离出lib包,实现lib包与项目代码分离_springboot打包分离lib_独行客-编码爱好者的博客-CSDN博客