@Component public class SpringContextAware extends Object implements org.springframework.context.ApplicationContextAware
| Constructor and Description |
|---|
SpringContextAware() |
| Modifier and Type | Method and Description |
|---|---|
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为对象实例)
|
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 - 对象Copyright © 2019. All rights reserved.