In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces how to access static resources in Spring Boot 2.x, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
First, take a look at the definition of the autoconfiguration class:
This is because there are conditional comments on the web autoconfiguration class WebMvcAutoConfiguration of springboot
@ ConditionalOnMissingBean (WebMvcConfigurationSupport.class)
This annotation means that changing the automatic configuration class will not take effect until there is a lack of bean of type WebMvcConfigurationSupport in the project classpath, so you need to rewrite the corresponding method after inheriting WebMvcConfigurationSupport.
If you want to use automatic configuration to take effect, and you have to override some methods as needed, such as adding viewController, you can inherit the WebMvcConfigurerAdapter class from your own configuration class. However, this class has been discarded with WebMvcConfigurerAdapter since the spring5.0 version, and although it works, it doesn't look good.
/ * this is what it says: * public class BeanConfiguration extends WebMvcConfigurationSupport * causes the default configuration of static resources to become invalid * / @ Configurationpublic class BeanConfiguration implements WebMvcConfigurer {@ Bean public MappingJackson2HttpMessageConverter jackson2HttpMessageConverter () {MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter (); ObjectMapper mapper = new ObjectMapper (); mapper.configure (DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.setDateFormat (new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss")) Mapper.setTimeZone (TimeZone.getTimeZone ("GMT+8")); mapper.setDefaultPropertyInclusion (JsonInclude.Include.ALWAYS); converter.setObjectMapper (mapper); return converter;} @ Override public void configureMessageConverters (List)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.