在 Maven/Tomcat 的启动日志里,真正导致失败的异常永远出现在最下面 ,而且以 Caused by:
开头 。
记住下面 3 步 10 秒就能锁定问题:
✅ 1 秒找"最底层"
直接 从下往上扫,第一个出现的
Caused by:
就是根因。
(前面所有 LifecycleException
都只是外层包装)
✅ 2 秒看异常类型 + 描述
把 Caused by:
后面 异常类名 + 冒号后的第一句话 复制出来,例如:
Caused by: java.lang.IllegalArgumentException: createServletApplicationContext() must not return null
- 类名 → 告诉你哪一类问题(空指针、端口冲突、配置错误...)
- 描述 → 告诉你具体原因
✅ 3 秒定位代码行
如果日志里有
at com.xxx.YourClass.method(YourClass.java:42)
直接双击 IDEA 里的日志行,就能跳到对应代码。
🔍 实战速查表
常见关键字 | 含义 | 快速处理 |
---|---|---|
Address already in use |
端口被占 | 换端口 or 杀进程 |
ClassNotFoundException |
缺依赖 | 加 jar / 检查 scope |
NullPointerException |
空指针 | 看行号,判空 |
Servlet mapping 冲突 |
URL 重复 | 全局搜 @WebServlet |
createServletApplicationContext() must not return null |
Spring 配置错 | 返回非空 context |
✅ 一句话背下来
"从下往上找第一个
Caused by:
,复制异常类+描述,按行号回代码,问题 10 秒定位。"