springboot启动直接退出显示Process finished with exit code 1

SprintBoot项目启动后直接退出(未打印有关SP的日志)


一、解决思路

尝试在main方法前面加了一行打印语句:
System.out.println(“SpringBoot Start…”);

//正常运行的打印信息
SpringBoot Start....
Process finished with exit code 1

有出现上面的信息说明程序入口没有问题,需要捕获异常。

使用try catch捕获run()方法的异常;

try {
  SpringApplication.run(Application.class, args);
}catch(Exception e) {
  e.printStackTrace();
}

若还是没有发现异常,将Exception换成Throwable(最顶级的异常类)

try {
  SpringApplication.run(Application.class, args);
}catch(Throwable e) {
  e.printStackTrace();
}

二、解决方案

根据异常信息下寻找问题的解决方法。
一般情况下,出现的问题会有:
1、项目代码格式问题;
2、编译类未正常引用;
3、jar包依赖冲突;

posted @ 2022-11-10 11:02  LightGrass  阅读(1295)  评论(0)    收藏  举报