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 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:
      postProcessBeanFactory in interface org.springframework.beans.factory.config.BeanFactoryPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • getApplicationContext

      public static org.springframework.context.ApplicationContext getApplicationContext()
      获取ApplicationContext
      Returns:
      ApplicationContext
    • getBeanFactory

      public static org.springframework.beans.factory.ListableBeanFactory getBeanFactory()
      获取ListableBeanFactory,可能为ConfigurableListableBeanFactoryApplicationContextAware
      Returns:
      ListableBeanFactory
    • getBean

      public static <T> T getBean(String name)
      通过name获取 Bean
      Type Parameters:
      T - Bean类型
      Parameters:
      name - Bean名称
      Returns:
      Bean
    • getBean

      public static <T> T getBean(Class<T> clazz)
      通过class获取Bean
      Type Parameters:
      T - Bean类型
      Parameters:
      clazz - Bean类
      Returns:
      Bean对象
    • getBean

      public static <T> T getBean(String name, Class<T> clazz)
      通过name,以及Clazz返回指定的Bean
      Type Parameters:
      T - bean类型
      Parameters:
      name - Bean名称
      clazz - bean类型
      Returns:
      Bean对象
    • getProperty

      public static String getProperty(String key)
      获取配置文件配置项的值
      Parameters:
      key - 配置项key
      Returns:
      属性值