Spring Boot部署Wildfly遇异常:1.5/2.0版本报错,1.2.7可正常启动
Hey Brian, let’s break down what’s happening here and how to fix it.
HttpPutFormContentFilter Class Modifier Change In Spring Boot 1.2.x (like your working 1.2.7 version), the org.springframework.boot.web.filter.HttpPutFormContentFilter was a non-final class that could be inherited. But starting from Spring Boot 1.3.x (including the 1.5.10.RELEASE and 2.0.0 versions you’re having trouble with), this class was updated to be final.
If your code (or any third-party dependency you’re using) has a custom Filter that extends this class, that’s exactly why you’re seeing the "cannot inherit from final class" exception—it’s a direct conflict with the updated class structure in newer Spring Boot versions.
1. Check Your Code & Dependencies
- First, scan your own codebase for any class that extends
HttpPutFormContentFilter. If you find one, refactor it immediately: instead of inheriting the class, use composition to reuse its logic, or reimplement the Filter interface from scratch based on your needs. - If your code doesn’t have such a class, the issue is likely coming from a third-party dependency (like an old custom starter or internal company component). Run a dependency tree check to find the culprit:
- For Maven:
mvn dependency:tree - For Gradle:
./gradlew dependencies
Once you identify the problematic dependency, either:- Upgrade it to a version that’s compatible with Spring Boot 1.5+/2.0, or
- Exclude the default
HttpPutFormContentFilterauto-configuration (see step 2) and implement the required functionality yourself.
- For Maven:
2. Exclude the Auto-Configuration
If you need to disable the default HttpPutFormContentFilter setup, you can do this in two ways:
Option 1: Annotation on Your Starter Class
Add the exclude to your @SpringBootApplication annotation:
@SpringBootApplication(exclude = HttpPutFormContentFilterAutoConfiguration.class) public class YourApplication { public static void main(String[] args) { SpringApplication.run(YourApplication.class, args); } }
Option 2: Property File Configuration
Add this line to your application.properties:
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.web.HttpPutFormContentFilterAutoConfiguration
Or in application.yml:
spring: autoconfigure: exclude: org.springframework.boot.autoconfigure.web.HttpPutFormContentFilterAutoConfiguration
After excluding it, you can write a custom Filter to handle PUT request form content if your application still needs that functionality.
3. Verify Dependency Version Compatibility
It’s also worth double-checking that all your project’s dependencies are compatible with your target Spring Boot version. Old versions of Spring Cloud, security libraries, or other Spring ecosystem components can cause version conflicts that lead to weird class-loading errors. Use the dependency tree command mentioned earlier to spot mismatched versions, then adjust them to align with your Spring Boot release.
When upgrading Spring Boot versions, always review the official Release Notes and pay close attention to the "Breaking Changes" section. This will help you catch API or class structure changes like this one before they cause issues in your project.
内容的提问来源于stack exchange,提问作者Brian S

