Spring核心功能点梳理
2024-05-09 17:34:15 0 举报
AI智能生成
提炼Spring的9大核心功能
作者其他创作
大纲/内容
数据绑定
PropertyValues
PropertyValue的集合
存储key:value
I:BeanWrapper
DataBinder
数据绑定的基础上可进行数据校验
SpringMVC中的@Valid
泛型处理
ResolvableType(工具类)
国际化
Java中的国际化
Locale
ResourceBundle
MessageFormat
Spring中的国际化
I:MessageSource
Impl:ResourceBundleMessageSource
I:BeanFactory(IOC)
ListableBeanFactory
提供了一些获取集合的功能,比如有的接口可能有多个实现,通过这些方法就可以获取这些实现对象的集合。
HierarchicalBeanFactory
获取父容器
ConfigurableBeanFactory
配置BeanFactory
AutowireCapableBeanFactory
提供了自动装配Bean的实现、属性填充、初始化、处理获取依赖注入对象的功能
核心实现
DefaultListableBeanFactory
Impl:BeanDefinitionRegistry
I:BeanDefinition
读取BeanDefinition
BeanDefinitionReader
XmlBeanDefinitionReader
PropertiesBeanDefinitionReader
AnnotatedBeanDefinitionReader
ClassPathBeanDefinitionScanner
@Component底层实现
BeanDefinitionRegistry
BeanDefinition的注册中心,用于保存BeanDefinition
I:ApplicationContext
类定义
ApplicationContext继承了这些接口,但是ApplicationContext对于接口的实现是通过一种委派的方式
CI:ConfigurableApplicationContext
A:AbstractApplicationContext
事件
观察者模式/解耦
Spring Event
A:ApplicationEvent
I:ApplicationListener
I:ApplicationEventPublisher
spring内置事件
ContextRefreshEvent
ContextStartedEvent
ContextStoppedEvent
ContextCloseEvent
资源管理
java资源管理
URL
URLConnection
URLStreamHandler
spring资源管理
资源抽象
Resource
FileSystemResource
UrlResource
ClassPathResource
ByteArrayResource
WritableResource
资源加载
I:ResourceLoader
getResource
只需要一个路径
c:DefaultResourceLoader
I:ResourcePatternResolver
PathMatchingResourcePatternResolver
环境
Environment
propertyResolver
getProperty(String key)
getProperty(String key,Class<T> targetType)
resolvePlaceholders(String key)
配置属性源PropertySource
遍历PropertySource找到第一个就反馈,
当同时存在多个的时候,优先级最高的为第一个获取到的key
当同时存在多个的时候,优先级最高的为第一个获取到的key
SpringBoot解析配置文件
I:PropertySourceLoader
implements
YamlPropertySourceLoader
PropertiesPropertySourceLoader
methods
String[] getFileExtensions
List<PropertySource<?>> load(String name,Resource resource) throws IOException
类型转换
I:PropertyEditor(jdk)
void setValue(Object value)
Object getValue()
String getAsText()
void setAsText(String text)
I:Converter
T convert(S source)
GenericConverter
Set<ConvertiblePair> getConvertibleTypes()
Object convert(@Nullable Object source,TypeDescriptor sourceType,TypeDescriptor targetType)
ConversionService
Impl:GenericConversionService
Impl:ConverterRegistry
addConverter
springboot中使用
DefaultConversionService
ApplicationConversionService
TypeConverter
Environment进行类型转换
I:ConfigurableEnvironment
I:ConfigurablePropertyResolver

收藏
0 条评论
下一页