1

org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter is deprecated and org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping error in mvc-dispatcher.xml. Why could it be ? please help mee ?

code as such the following

<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<bean id="urlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <props>
            <prop key="saveGeoJSON.html">HspatialController</prop>
        </props>
    </property>
</bean>

DefaultAnnotationHandlerMapping and AnnotationMethodHandlerAdapter is strikethrough

develop
  • 131
  • 6
  • 16

1 Answers1

4

You should replace those classes by RequestMappingHandlerMapping and RequestMappingHandlerAdapter if you are using Spring 3.1 and higher.

If you check the Spring 3.1 reference documentation, you'll see why those classes have been deprecated :

Spring 3.1 introduces a new set of support classes for processing requests with annotated controllers:

RequestMappingHandlerMapping

RequestMappingHandlerAdapter

ExceptionHandlerExceptionResolver

These classes are a replacement for the existing:

DefaultAnnotationHandlerMapping

AnnotationMethodHandlerAdapter

AnnotationMethodHandlerExceptionResolver

The new classes were developed in response to many requests to make annotation controller support classes more customizable and open for extension. Whereas previously you could configure a custom annotated controller method argument resolver, with the new support classes you can customize the processing for any supported method argument or return value type.

A second notable difference is the introduction of a HandlerMethod abstraction to represent an @RequestMapping method. This abstraction is used throughout by the new support classes as the handler instance. For example a HandlerInterceptor can cast the handler from Object to HandlerMethod and get access to the target controller method, its annotations, etc.

The new classes are enabled by default by the MVC namespace and by Java-based configuration via @EnableWebMvc. The existing classes will continue to be available but use of the new classes is recommended going forward.

Jean-Philippe Bond
  • 10,089
  • 3
  • 34
  • 60
  • my code changed as such the following org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping but still 406 error Can you help me with this? – develop Aug 09 '15 at 11:20
  • An error 406 means that the resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request. Do you have an header limitation for Accept in your Controller? Can you post your controller's code? – Jean-Philippe Bond Aug 09 '15 at 11:43