java.lang.Object
io.github.mangocrisp.spring.taybct.tool.core.util.SpringUtil
所有已实现的接口:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.context.ApplicationContextAware

@AutoConfiguration public class SpringUtil extends Object implements org.springframework.beans.factory.config.BeanFactoryPostProcessor, org.springframework.context.ApplicationContextAware
spring 工具类
从以下版本开始:
1.0.0
  • 构造器详细资料

    • SpringUtil

      public SpringUtil()
  • 方法详细资料

    • postProcessBeanFactory

      public void postProcessBeanFactory(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory) throws org.springframework.beans.BeansException
      指定者:
      postProcessBeanFactory 在接口中 org.springframework.beans.factory.config.BeanFactoryPostProcessor
      抛出:
      org.springframework.beans.BeansException
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      指定者:
      setApplicationContext 在接口中 org.springframework.context.ApplicationContextAware
      抛出:
      org.springframework.beans.BeansException
    • getBean

      public static <T> T getBean(String name) throws org.springframework.beans.BeansException
      获取对象
      参数:
      name - bean 名
      返回:
      Object 一个以所给名字注册的bean的实例
      抛出:
      org.springframework.beans.BeansException
    • getBean

      public static <T> T getBean(Class<T> clz) throws org.springframework.beans.BeansException
      获取类型为requiredType的对象
      参数:
      clz - 类型
      抛出:
      org.springframework.beans.BeansException
    • containsBean

      public static boolean containsBean(String name)
      如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true
      参数:
      name - bean 名
      返回:
      boolean
    • isSingleton

      public static boolean isSingleton(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
      判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException)
      参数:
      name - bean 名
      返回:
      boolean
      抛出:
      org.springframework.beans.factory.NoSuchBeanDefinitionException
    • getType

      public static Class<?> getType(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
      参数:
      name - bean 名
      返回:
      Class 注册对象的类型
      抛出:
      org.springframework.beans.factory.NoSuchBeanDefinitionException
    • getAliases

      public static String[] getAliases(String name) throws org.springframework.beans.factory.NoSuchBeanDefinitionException
      如果给定的bean名字在bean定义中有别名,则返回这些别名
      参数:
      name - bean 名
      抛出:
      org.springframework.beans.factory.NoSuchBeanDefinitionException
    • getAopProxy

      public static <T> T getAopProxy(T invoker)
      获取aop代理对象
    • getActiveProfiles

      public static String[] getActiveProfiles()
      获取当前的环境配置,无配置返回null
      返回:
      当前的环境配置
    • getActiveProfile

      public static String getActiveProfile()
      获取当前的环境配置,当有多个环境配置时,只获取第一个
      返回:
      当前的环境配置
    • getBean

      public static <T> T getBean(String beanName, Class<T> clazz)
    • getContext

      public static org.springframework.context.ApplicationContext getContext()
    • publishEvent

      public static void publishEvent(org.springframework.context.ApplicationEvent event)
    • registerBean

      public static <T> T registerBean(String name, Class<T> clazz, Object... args)
      注册 bean
      参数:
      name - 自定义 bean name
      clazz - 注册的 bean 的类型
      args - 构造方法的必要参数,顺序和类型要求和 clazz 中定义的一致
    • registerBean

      public static <T> T registerBean(Class<? extends T> clazz, String beanName)
      注册 bean
      参数:
      clazz - 继承/实现类
      beanName - bean 名
      返回:
      如果有相同的 bean 名的 bean 就会直接返回这个已经存在的 bean
    • registerBean

      public static <T> T registerBean(String name, String beanName)
      注册自定义 bean
      参数:
      name - 自定义 bean name
      beanName - 原 bean name
    • autowireBean

      public static <T> T autowireBean(T existingBean)
      自动注入依赖
      类型参数:
      T - bean
      参数:
      existingBean - 需要自动注入依赖的 bean
      返回:
      bean