mattbertolini / spring-annotated-web-data-binder

Bind query params, form data, headers, cookies, session data, and more to a Java bean in Spring MVC and Spring WebFlux
Apache License 2.0
27 stars 4 forks source link

Getting WebRequestDataBinder class cast exception with Spring boot 3.x version #12

Open github-narendar opened 1 month ago

github-narendar commented 1 month ago

Hi @mattbertolini I started using this library to replace multiple @RequestParam and @PathVariable annotation for a cleaner code. But, getting below error at runtime. I am using spring boot 3.x latest version.

class org.springframework.web.servlet.mvc.method.annotation.ExtendedServletRequestDataBinder cannot be cast to class org.springframework.web.bind.support.WebRequestDataBinder (org.springframework.web.servlet.mvc.method.annotation.ExtendedServletRequestDataBinder and org.springframework.web.bind.support.WebRequestDataBinder are in unnamed module of loader 'app')

Help is appreciated.

mattbertolini commented 1 month ago

Hi @github-narendar. This error usually happens when multiple versions of the Spring Framework are on the classpath. This makes sense in this case as you're using Spring Boot 3.x and this library doesn't currently support version 3.x. This probably means Spring 2.x is also being pulled in causing the error.

I have a branch with Spring Boot 3.x support in progress but it's a large change and I haven't had much time to work on it. I'm not sure when I will be complete the work.

github-narendar commented 1 month ago

Hi @github-narendar. This error usually happens when multiple versions of the Spring Framework are on the classpath. This makes sense in this case as you're using Spring Boot 3.x and this library doesn't currently support version 3.x. This probably means Spring 2.x is also being pulled in causing the error.

I have a branch with Spring Boot 3.x support in progress but it's a large change and I haven't had much time to work on it. I'm not sure when I will be complete the work.

@mattbertolini Thanks for the quick reply. I will look for some other alternative for time being. This is the only library I found in internet which is met my requirement and perfectly does job what I am looking for.

mattbertolini commented 1 month ago

@github-narendar I published version 1.0.0-SNAPSHOT to the Maven Central snapshots repository (https://oss.sonatype.org/content/repositories/snapshots/). This version should be compatible with Spring Boot 3.x. If you want to try it out and see if it works that would be great. If it works, I can publish the release version to Maven Central.