类 SpringUtil

  • 所有已实现的接口:
    org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

    @Component("gybytSpringUtil")
    public class SpringUtil
    extends Object
    implements org.springframework.context.ApplicationContextAware
    spring 工具类
    • 构造器详细资料

      • SpringUtil

        public SpringUtil()
    • 方法详细资料

      • setApplicationContext

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

        public static <T> T getBean​(Class<T> clazz)
        根据类获取bean
        类型参数:
        T -
        参数:
        clazz -
        返回:
      • getBean

        public static <T> T getBean​(String beanName)
        根据beanId获取对象
        类型参数:
        T -
        参数:
        beanName -
        返回:
      • getBean

        public static <T> T getBean​(Class<T> clazz,
                                    String beanName)
        根据beanId、类型获取对象
        类型参数:
        T -
        参数:
        beanName -
        clazz -
        返回:
      • getBeansOfType

        public static <T> Map<String,​T> getBeansOfType​(Class<T> clazz)
        根据类型获取对象集合
        类型参数:
        T -
        参数:
        clazz -
        返回:
      • getContext

        public static org.springframework.context.ApplicationContext getContext()
        获取ApplicationContext对象
        返回:
      • publishEvent

        public static void publishEvent​(org.springframework.context.ApplicationEvent event)
        发布事件
        参数:
        event -
      • getServletRequest

        public static javax.servlet.http.HttpServletRequest getServletRequest()
        获取请求对象
        返回:
      • getServletResponse

        public static javax.servlet.http.HttpServletResponse getServletResponse()
        获取响应对象
        返回:
      • getRequestParam

        public static Map<String,​String> getRequestParam()
        获取请求参数map
        返回:
      • getRequestBody

        public static String getRequestBody()
        获取请求体
        返回:
      • getRequestBodyByte

        public static byte[] getRequestBodyByte()
        获取请求体
        返回:
      • getRequestHeaders

        public static Map<String,​String> getRequestHeaders()
        获取请求头
        返回:
      • getResponseHeaders

        public static Map<String,​String> getResponseHeaders()
        获取响应头
        返回:
      • addProperty

        public static void addProperty​(String key,
                                       String value,
                                       Boolean isReplace)
        添加环境变量
        参数:
        key -
        value -
        isReplace -
      • addProperty

        public static void addProperty​(Object key,
                                       Object value,
                                       Boolean isReplace)
        添加环境变量
        参数:
        key -
        value -
        isReplace -
      • addProperty

        public static void addProperty​(Map<Object,​Object> map,
                                       Boolean isReplace)
        添加环境变量
        参数:
        map -
        isReplace -
      • getProperty

        public static String getProperty​(String key)
        获取环境变量
        参数:
        key -
        返回:
      • getProperty

        public static Object getProperty​(Object key)
        获取环境变量
        参数:
        key -
        返回:
      • getPropertiesMap

        public static Map<Object,​Object> getPropertiesMap()
        获取所有环境变量
        返回:
      • getPropertiesMap

        public static Map<Object,​Object> getPropertiesMap​(Set<Object> keySet)
        获取环境变量集合,传入变量名称set集合
        参数:
        keySet -
        返回: