@Component public class SpringUtils extends Object implements org.springframework.context.ApplicationContextAware
1、Spring IOC容器中的bean对象获取
Constructor and Description |
---|
SpringUtils() |
Modifier and Type | Method and Description |
---|---|
static org.springframework.context.ApplicationContext |
getApplicationContext()
获取applicationContext
|
static <T> T |
getBean(Class<T> clazz)
通过class获取Bean
|
static Object |
getBean(String name)
通过name获取 Bean
|
static <T> T |
getBean(String name,
Class<T> clazz)
通过name,以及Clazz返回指定的Bean
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
public static org.springframework.context.ApplicationContext getApplicationContext()
public static Object getBean(String name)
name
- Bean名称public static <T> T getBean(Class<T> clazz)
T
- Bean类型clazz
- Bean类Copyright © 2022 Pivotal Software, Inc.. All rights reserved.