Honza
Honza

Reputation: 4409

WebMvcAutoConfiguration not being activated

I have a fairly simple spring-boot app and upon debugging issues with cache-busting resource URL generation discovered that WebMvcAutoConfiguration is not being triggered on application start.

Here is the relevant log output:

WebMvcAutoConfiguration:
  Did not match:
     - @ConditionalOnMissingBean (types: org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; SearchStrategy: all) found beans of type 'org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport' org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration (OnBeanCondition)
  Matched:
     - @ConditionalOnClass found required classes 'javax.servlet.Servlet', 'org.springframework.web.servlet.DispatcherServlet', 'org.springframework.web.servlet.config.annotation.WebMvcConfigurer'; @ConditionalOnMissingClass did not find unwanted class (OnClassCondition)
     - found ConfigurableWebEnvironment (OnWebApplicationCondition)

Upon debugging this for a couple of hours and comparing a empty-app behaviour with mine the only difference I found is that there are more MvcConfigurer instances in my app. Namely:

I would thing that these things would be able to co-exist side by side but apparently there is something else at play.

Now I am at a loss because I have spent hours debugging this issue.

My question is how to find the source of this missing DelegatingWebMvcConfiguration bean thats disabling the WebMvcAutoConfiguration?

Upvotes: 2

Views: 2938

Answers (1)

Michel Néron
Michel Néron

Reputation: 63

I just have this problem with SpringBoot 2.1.3.RELEASE, It long time before anwser but maybe help other.

The solution it's just remove the @EnableWebMvc.

If you look the EnableWebMvc class, it import directly the DelegatingWebMvcConfiguration, so when the WebMvcAutoConfiguration verify the condition it's found DelegatingWebMvcConfiguration beans.

And without EnableWebMvc the WebMvcAutoConfiguration is take and it have a static configuration :

@Configuration
public static class EnableWebMvcConfiguration extends DelegatingWebMvcConfiguration

Maybe this have other impact, but I just start my project and I cannot verify.

Upvotes: 2

Related Questions