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.ServletRegistrationBeanwithorg.springframework.boot.web.servlet.ServletRegistrationBean. Don’t forget to check for related classes likeFilterRegistrationBeanif 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.ServletRegistrationBeanto 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
- For Maven:
That should resolve the class-not-found error and let your application context load properly.
内容的提问来源于stack exchange,提问作者Anurag Jain
相关产品推荐
相关产品推荐

