After the spring boot custom configuration class inherits Webmvcconfigurationsupport, it discovers the static resource path that is automatically configured (classpath:/meta/resources/,classpath:/resources/ , classpath:/static/,classpath:/public/) does not take effect.
First look at the definition of the automatic configuration class:
This is because there are conditional annotations on the Springboot Web Autoconfiguration class Webmvcautoconfiguration
@ConditionalOnMissingBean (Webmvcconfigurationsupport. Class)
This annotation means that the automatic configuration class will not take effect until the Webmvcconfigurationsupport type bean is missing from the project Classpath, so the inheritance Webmvcconfigurationsupport Later, you need to rewrite the corresponding method.
If you want to use automatic configuration to take effect and rewrite some methods as you want, such as adding Viewcontroller, you can inherit the Webmvcconfigureradapter class from your own configuration class. However, after the spring5.0 version this class was discarded webmvcconfigureradapter , although it can be used, but looks bad = =.
This is a comment on the class, meaning that spring 5.0 uses JAVA8, and the interface in JAVA8 can have the default method, so this class is not necessary. So we just need to implement it directly in the custom configuration class.
The interface is good. As follows:
Spring boot inherits Webmvcconfigurationsupport after automatic configuration does not take effect