public class SpringBeanUtil extends Object implements org.springframework.context.ApplicationContextAware
Utility class for get bean.
| 构造器和说明 |
|---|
SpringBeanUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static org.springframework.context.ApplicationContext |
getApplicationContext()
Get application context
|
static <T> T |
getBean(Class<T> clazz)
Get bean by the given object type
|
static Object |
getBean(String name)
Get bean by the given name
|
static <T> T |
getBean(String name,
Class<T> clazz)
Get bean by the name and given object type
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext 在接口中 org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic static org.springframework.context.ApplicationContext getApplicationContext()
public static Object getBean(String name)
name - the name of the bean to retrievepublic static <T> T getBean(Class<T> clazz)
clazz - type the bean must match; can be an interface or superclassCopyright © 2020. All rights reserved.