You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot从1.4.4RELEASE升级到1.5.12RELEASE加载上下文报错求助

Fixing ClassNotFoundException: org.springframework.boot.context.embedded.ServletRegistrationBean When Upgrading to Spring Boot 1.5.x

Hey, I’ve dealt with this exact problem during a Spring Boot version upgrade—let’s get this sorted out for you.

What’s Causing the Error?

Spring Boot 1.5.x reorganized web-related classes to align with modern Servlet standards. The ServletRegistrationBean class (along with similar ones like FilterRegistrationBean and ServletListenerRegistrationBean) was moved from:

org.springframework.boot.context.embedded

to:

org.springframework.boot.web.servlet

Your code is still referencing the old package path, which no longer exists in Spring Boot 1.5.12.RELEASE—hence the ClassNotFoundException.

Step-by-Step Fix

  • Update import statements: Go through all your Java files and replace any imports pointing to org.springframework.boot.context.embedded.ServletRegistrationBean with org.springframework.boot.web.servlet.ServletRegistrationBean. Don’t forget to check for related classes like FilterRegistrationBean if you use them—they moved to the same new package too.
  • Check XML configurations (if applicable): If you define beans in XML, update the full class name from org.springframework.boot.context.embedded.ServletRegistrationBean to the new package path.
  • Clean and rebuild your project: Old class files or cached dependencies might still be lingering. Run:
    • For Maven: mvn clean install
    • For Gradle: ./gradlew clean build

That should resolve the class-not-found error and let your application context load properly.

内容的提问来源于stack exchange,提问作者Anurag Jain

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:20:19