Spring Boot - 让人抓狂的ClassNotFoundException

基于Spring Boot + Maven的项目在某些环境下启动时遇到ClassNotFoundException,主要涉及javax.servlet.http.HttpServletResponse。排查过程包括排除JDK设置问题,研究Servlet容器加载问题。通过重新安装IDE和更新项目依赖解决,问题出在web server容器,特别是spring boot内嵌的Tomcat。更新Maven依赖并重新编译后,问题得到解决。分享经验以帮助遇到相同问题的开发者。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

我们的项目基于Spring Boot + Maven,采用Intelli IDEA工具进行开发。代码在另一名同事的机器上检出之后,启动项目时,始终出现如下错误提示:

03-11 15:41:23[org.springframework.boot.SpringApplication-825][main][13298] - Application startup failed
java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletResponse
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.getDeclaredMethods(Class.java:1975)
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:609)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:521)
at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:507)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:241)
at org.springframework.beans.factory.support.AbstractAutowireCapa
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sisi.li8

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值