SpringBoot 项目找不到或无法加载主类
软件:IDEA 2023
从同事那里复制来的项目,使用 maven 方式构建,经过配置后,可以正常跑起来。打包生成 JAR 包时,生成的 JAR 包不能正常执行,错误如下:
错误: 找不到或无法加载主类 com.aliyuncs.aui.AuiAppserverApplication
原因: java.lang.ClassNotFoundException: com.aliyuncs.aui.AuiAppserverApplication
这里主要是我在 Project Structure 的 Artifacts 中添加了一个生成 JAR 包的 Artifact,但是生成 JAR 包后无法正常运行。
最后,上网查看,使用 maven 先 clean ,然后 package ,在 target 目录下生成了 JAR 包,这个 JAR 包可以正常运行。