springboot 项目部署在服务器上报错,如何解决?
在使用 springboot 部署在宝塔服务器时,遇到了无法识别类的错误。
报错信息:
exception in thread "main" java.lang.classnotfoundexception: classes.com.example.demo.demoapplication
解决方法:
首先,检查项目本身是否有问题,本地打包后运行是否有报错。
本地打包部署:
修改 maven 插件配置:
如果本地部署正常,可能是打包配置问题。在 pom.xml 中的 spring-boot-maven-plugin 配置中移除 configuration 和 executions 元素。
org.springframework.boot spring-boot-maven-plugin2.6.0
重新打包部署:
jar 文件。其他建议: