Hi, I submitted this PR to solve #30899 based on @wilkinsona ’s comment.
When I switched to BeanFactoryUtils.beansOfTypeIncludingAncestors, I found that still can't solve the problem, this is because the bean names of org.springframework.boot.actuate.autoconfigure.web.servlet.CompositeHandlerExceptionResolver and org.springframework.web.servlet.handler.HandlerExceptionResolverComposite are the same.
-
See
WebMvcEndpointChildContextConfiguration.java#L100-L101
https://github.com/spring-projects/spring-boot/blob/837e2ac277bf9496e07238431710251c083c7a0b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/WebMvcEndpointChildContextConfiguration.java#L100-L101
So when using BeanFactoryUtils.beansOfTypeIncludingAncestors, HandlerExceptionResolverComposite will be overwritten by CompositeHandlerExceptionResolver.
Maybe we need a variant of BeanFactoryUtils.beansOfTypeIncludingAncestors, use collection to collect HandlerExceptionResolver instead of map, or modify the bean name of CompositeHandlerExceptionResolver, I chose the former for now.
Closes gh-30899
Comment From: philwebb
Thanks @terminux, this has now been merged to 2.6.x and forward.