Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring MVC: disable DefaultAnnotationHandlerMapping

I'm using Spring MVC with <mvc:annotation-driven />

I've implemented my own mapping handler extending DefaultAnnotationHandlerMapping, but I'm not sure how to use it. I've declared it like this:

<bean class="es.kcsolutions.boulevard.DispatcherMappingHandler" />

It works, but, obviously, DefaultAnnotationHandlerMapping works too and always before mine. Is there a way to disable it and use only mine?

Thanks.

like image 377
sinuhepop Avatar asked Nov 06 '22 12:11

sinuhepop


1 Answers

My advice would be to remove the <mvc:annotation-driven /> altogether. It doesn't really do anything particularly useful - most of the beans it declares are there already. And in cases where you want to declare your own handler mapping or handler adapter, it just gets in the way.

So take it out, declare your own DefaultAnnotationHandlerMapping bean, and it should work. No need to mess about with ordering in 99.9% of cases.

like image 199
skaffman Avatar answered Nov 11 '22 06:11

skaffman