Package tech.mgl.expand
Class MGL_SpringUtils
java.lang.Object
tech.mgl.expand.MGL_SpringUtils
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.config.BeanFactoryPostProcessor,org.springframework.context.ApplicationContextAware
@Component
public class MGL_SpringUtils
extends Object
implements org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.context.ApplicationContextAware
Spring(Spring boot)工具封装
- Since:
- 5.5.6
- Author:
- bo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.springframework.context.ApplicationContext获取ApplicationContextstatic <T> T通过class获取Beanstatic <T> T通过name获取 Beanstatic <T> T通过name,以及Clazz返回指定的Beanstatic org.springframework.beans.factory.ListableBeanFactory获取ListableBeanFactory,可能为ConfigurableListableBeanFactory或ApplicationContextAwarestatic StringgetProperty(String key) 获取配置文件配置项的值voidpostProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
Constructor Details
-
MGL_SpringUtils
public MGL_SpringUtils()
-
-
Method Details
-
postProcessBeanFactory
public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException - Specified by:
postProcessBeanFactoryin interfaceorg.springframework.beans.factory.config.BeanFactoryPostProcessor- Throws:
org.springframework.beans.BeansException
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContextin interfaceorg.springframework.context.ApplicationContextAware
-
getApplicationContext
public static org.springframework.context.ApplicationContext getApplicationContext()获取ApplicationContext- Returns:
ApplicationContext
-
getBeanFactory
public static org.springframework.beans.factory.ListableBeanFactory getBeanFactory()获取ListableBeanFactory,可能为ConfigurableListableBeanFactory或ApplicationContextAware- Returns:
ListableBeanFactory
-
getBean
通过name获取 Bean- Type Parameters:
T- Bean类型- Parameters:
name- Bean名称- Returns:
- Bean
-
getBean
通过class获取Bean- Type Parameters:
T- Bean类型- Parameters:
clazz- Bean类- Returns:
- Bean对象
-
getBean
通过name,以及Clazz返回指定的Bean- Type Parameters:
T- bean类型- Parameters:
name- Bean名称clazz- bean类型- Returns:
- Bean对象
-
getProperty
获取配置文件配置项的值- Parameters:
key- 配置项key- Returns:
- 属性值
-