SpringBoot2核心技术
核心功能
配置文件
文件类型
properties
yaml
基本用法
key: valuekv之间有空格大小写敏感缩进不允许使用tab, 只允许空格缩进的空格数不重要, 只要相同层级的元素左对齐即可'#'表示注释字符串无需加引号, 如果要加,一些特殊字符会被转义
数据类型
date,boolean,string,number,nullmap,hash,set,object
示例
1 |
|
1 | igsshan: |
Web开发
Spring MVC Auto-configuration
Spring Boot provides auto-configuration for Spring MVC that works well with most applications. It replaces the need for @EnableWebMvc and the two cannot be used together. In addition to Spring MVC’s defaults, the auto-configuration provides the following features:
- Inclusion of
ContentNegotiatingViewResolverandBeanNameViewResolverbeans.- 包含
内容协商视图解析器和BeanName视图解析器
- 包含
- Support for serving static resources, including support for WebJars (covered later in this document ).
- 支持提供静态资源,包含对 WebJars的支持
- Automatic registration of
Converter,GenericConverter, andFormatterbeans.- 自动注册
Converter,GenericConverter和Formatter
- 自动注册
- Support for
HttpMessageConverters(covered later in this document ).- 支持
HttpMessageConverters
- 支持
- Automatic registration of
MessageCodesResolver(covered later in this document ).- 自动注册
MessageCodesResvoler
- 自动注册
- Static
index.htmlsupport.- 支持静态
index.html页面
- 支持静态
- Automatic use of a
ConfigurableWebBindingInitializerbean (covered later in this document ).- 自动使用
ConfigurableWebBindingInitializer
- 自动使用
If you want to keep those Spring Boot MVC customizations and make more MVC customizations (interceptors, formatters, view controllers, and other features), you can add your own @Configuration class of type WebMvcConfigurer but without @EnableWebMvc.
不使用
EnableWebMvc注解. 使用Configuration+WebConfigurer自定义规则
If you want to provide custom instances of RequestMappingHandlerMapping, RequestMappingHandlerAdapter, or ExceptionHandlerExceptionResolver, and still keep the Spring Boot MVC customizations, you can declare a bean of type WebMvcRegistrations and use it to provide custom instances of those components. The custom instances will be subject to further initialization and configuration by Spring MVC. To participate in, and if desired, override that subsequent processing, a WebMvcConfigurer should be used.
声明
WebMvcRegistrations改变默认底层组件
If you do not want to use the auto-configuration and want to take complete control of Spring MVC, add your own @Configuration annotated with @EnableWebMvc. Alternatively, add your own @Configuration-annotated DelegatingWebMvcConfiguration as described in the Javadoc of @EnableWebMvc.
使用
@EnableMvc+@Configuration+DelegatingWebMvcConfiguration全面接管 SpringMvc