davioooh davioooh - 1 year ago 278
Java Question

Cannot extend WebMvcAutoConfigurationAdapter in Spring Boot 1.4

I'd like to update a web project to Spring Boot 1.4 but I'm getting and error.

I'm currently using Spring Boot 1.3.3 and I'm extending

to map some custom resource hanlders:

public class MvcConfiguration extends WebMvcAutoConfigurationAdapter {

public void addResourceHandlers(ResourceHandlerRegistry registry) {
// ...


I noticed that in the new version of SB a constructor was added to

public WebMvcAutoConfigurationAdapter(ResourceProperties resourceProperties,
WebMvcProperties mvcProperties, ListableBeanFactory beanFactory,
HttpMessageConverters messageConverters,
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizerProvider) {}

and this constructor uses
that is a package-protected interface, so, basically, from version 1.4 is not possible to extend autoconfiguration.

What is an alternative way to extend autoconfiguration?

Answer Source

There's no need to extend WebMvcAutoConfigurationAdapter to add some custom resource handlers (and never has been). You should extend Spring MVC's WebMvcConfigurerAdapter instead.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download