public final class SpringUtils extends Object
ApplicationContext| 限定符和类型 | 字段和说明 |
|---|---|
static Supplier<? extends RuntimeException> |
BEAN_NOT_FOUND |
static Supplier<? extends RuntimeException> |
UNSUPPORTED |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> boolean |
containsBean(Class<?> beanType)
判断
ApplicationContext是否包含指定bean |
static boolean |
containsBean(String beanName)
判断
ApplicationContext是否包含指定bean |
static <T> Optional<T> |
getBean(Class<T> beanType)
获取指定类型Bean
|
static <T> Optional<T> |
getBean(Class<T> beanType,
String beanName)
获取指定类型Bean
|
static org.springframework.beans.factory.support.BeanDefinitionRegistry |
getBeanDefinitionRegistry()
获得
BeanDefinitionRegistry实例 |
static <T> List<T> |
getBeanList(Class<T> beanType)
获取所有指定类型Bean的实例
|
static org.springframework.core.convert.ConversionService |
getConversionService()
获取
ConversionService实例 |
static org.springframework.core.env.Environment |
getEnvironment()
获取
Environment实例 |
static org.springframework.context.MessageSource |
getMessageSource()
获取
MessageSource实例 |
static <T> org.springframework.beans.factory.ObjectProvider<T> |
getObjectProvider(Class<T> beanType)
获取
ObjectProvider实例 |
static <T> T |
getRequiredBean(Class<T> beanType)
获取指定类型Bean
|
static <T> T |
getRequiredBean(Class<T> beanType,
String beanName)
获取指定类型Bean
|
static org.springframework.core.io.ResourceLoader |
getResourceLoader()
获取
ResourceLoader实例 |
static org.springframework.core.io.support.ResourcePatternResolver |
getResourcePatternResolver()
获取
ResourcePatternResolver实例 |
static org.springframework.validation.Validator |
getValidator()
获取
Validator实例 |
public static final Supplier<? extends RuntimeException> UNSUPPORTED
public static final Supplier<? extends RuntimeException> BEAN_NOT_FOUND
public static org.springframework.beans.factory.support.BeanDefinitionRegistry getBeanDefinitionRegistry()
BeanDefinitionRegistry实例BeanDefinitionRegistry实例UnsupportedOperationException - 无法定位ApplicationContext实例BeanDefinitionRegistrypublic static <T> org.springframework.beans.factory.ObjectProvider<T> getObjectProvider(Class<T> beanType)
ObjectProvider实例T - 需要查找或生成的Bean类型泛型beanType - beanTypeObjectProvider实例UnsupportedOperationException - 无法定位ApplicationContext实例ObjectProviderpublic static org.springframework.core.io.ResourceLoader getResourceLoader()
ResourceLoader实例ResourceLoader实例UnsupportedOperationException - 无法定位ApplicationContext实例Resource,
ResourceLoader,
ResourcePatternResolver,
getResourcePatternResolver()public static org.springframework.core.io.support.ResourcePatternResolver getResourcePatternResolver()
ResourcePatternResolver实例ResourcePatternResolver实例UnsupportedOperationException - 无法定位ApplicationContext实例Resource,
ResourceLoader,
ResourcePatternResolver,
getResourceLoader()public static org.springframework.core.env.Environment getEnvironment()
Environment实例Environment实例UnsupportedOperationException - 无法定位ApplicationContext实例Environment,
EnvironmentUtils,
ProfilesUtilspublic static org.springframework.core.convert.ConversionService getConversionService()
ConversionService实例ConversionService实例UnsupportedOperationException - 无法定位ApplicationContext实例ConversionService,
Converter,
GenericConverter,
DefaultFormattingConversionService,
ConversionUtilspublic static org.springframework.validation.Validator getValidator()
Validator实例Validator实例UnsupportedOperationException - 无法定位ApplicationContext实例Validator,
ValidatorUtilspublic static org.springframework.context.MessageSource getMessageSource()
MessageSource实例MessageSource实例UnsupportedOperationException - 无法定位ApplicationContext实例MessageSource,
MessageSourceAccessor,
MessageUtilspublic static <T> Optional<T> getBean(Class<T> beanType)
T - 指定类型泛型beanType - 指定类型UnsupportedOperationException - 无法定位ApplicationContext实例public static <T> Optional<T> getBean(Class<T> beanType, String beanName)
T - 指定类型泛型beanType - 指定类型beanName - bean名称UnsupportedOperationException - 无法定位ApplicationContext实例public static <T> T getRequiredBean(Class<T> beanType)
T - 指定类型泛型beanType - 指定类型UnsupportedOperationException - 无法定位ApplicationContext实例org.springframework.beans.factory.NoSuchBeanDefinitionException - 无法查找到Beanpublic static <T> T getRequiredBean(Class<T> beanType, String beanName)
T - 指定类型泛型beanType - 指定类型beanName - bean名称UnsupportedOperationException - 无法定位ApplicationContext实例org.springframework.beans.factory.NoSuchBeanDefinitionException - 无法查找到Beanpublic static <T> List<T> getBeanList(Class<T> beanType)
T - 指定类型泛型beanType - 指定类型UnsupportedOperationException - 无法定位ApplicationContext实例public static boolean containsBean(String beanName)
ApplicationContext是否包含指定beanbeanName - bean名称UnsupportedOperationException - 无法定位ApplicationContext实例public static <T> boolean containsBean(Class<?> beanType)
ApplicationContext是否包含指定beanT - bean类型泛型beanType - bean类型UnsupportedOperationException - 无法定位ApplicationContext实例Copyright © 2022. All rights reserved.