@Component public class SpringAware extends Object implements org.springframework.context.ApplicationContextAware
| Constructor and Description |
|---|
SpringAware() |
| Modifier and Type | Method and Description |
|---|---|
static String |
getActiveProfile()
获取当前profile
默认获取第一个
|
static org.springframework.context.ApplicationContext |
getApplicationContext()
取得存储在静态变量中的ApplicationContext.
|
static <T> T |
getBean(Class<T> clazz)
从静态变量ApplicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
static <T> T |
getBean(String name)
从静态变量ApplicationContext中取得Bean, 自动转型为所赋值对象的类型.
|
static <T> Map<String,T> |
getBeanOfType(Class<T> requiredType)
依据类型获取所有子类(key为spring的id,value为对象实例)
|
static Map<String,Object> |
getBeansWithAnnotation(Class<? extends Annotation> annType)
获取指定注解的Bean
|
static boolean |
isDemoMode()
当前是否开发/测试模式
|
static boolean |
isDevMode()
当前是否开发环境
|
static boolean |
isTestMode()
当前是否测试环境
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
public static org.springframework.context.ApplicationContext getApplicationContext()
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext in interface org.springframework.context.ApplicationContextAwarepublic static <T> T getBean(String name)
T - 对象name - 名称public static <T> T getBean(Class<T> clazz)
T - 对象clazz - 对象public static <T> Map<String,T> getBeanOfType(Class<T> requiredType) throws org.springframework.beans.BeansException
T - 对象requiredType - 类型org.springframework.beans.BeansException - 异常public static Map<String,Object> getBeansWithAnnotation(Class<? extends Annotation> annType)
获取指定注解的BeanannType - 指定注解类型public static String getActiveProfile()
获取当前profile
默认获取第一个public static boolean isDemoMode()
public static boolean isDevMode()
public static boolean isTestMode()
Copyright © 2019. All rights reserved.