SpringBoot项目部署Linux报错IllegalArgumentException: name,如何解决?

springboot 项目部署 linux 报错 illegalargumentexception: name

问题描述:

在 intellij idea 环境中正常运行的 springboot 项目,部署到 linux 系统后无法启动,抛出 illegalargumentexception: name 异常。

排查过程:

  • 检查项目中相关参数配置是否正确。
  • 查看 mybatis-plus 配置是否在 idea 中和 linux 环境中保持一致。

解决方法:

经过排查,发现问题出在打包阶段。查看 manifest.mf 文件,发现缺少 start-class 属性,导致 springboot 无法找到应用程序入口。

  • 使用 jdk 8 时,错误提示为 "name"。
  • 使用 jdk 17 时,

    错误提示为 "mainclass" 找不到。

解决方案:

在构建配置中指定 springbootapplication 类的全限定名作为 main-class。


    
        
            org.springframework.boot
            spring-boot-maven-plugin
            
                com.example.demo.Application
            
        
    

解决此问题耗时较长,由于 jdk 1.8 对该异常提示的的信息不足,导致排查方向出现偏差。