类 SpringBeanService
java.lang.Object
com.luna.common.spring.SpringBeanService
- 所有已实现的接口:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
@Component
public class SpringBeanService
extends Object
implements org.springframework.context.ApplicationContextAware
Spring的bean加载服务类
-
字段概要
字段修饰符和类型字段说明protected static org.springframework.context.ApplicationContextspring bean上下文 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static ObjectgetBeanByName(String name) 获取bean实例static <T> TgetBeanByName(String name, Class<T> clazz) 获取bean实例getBeansOfType(Class<T> clazz) 获取此类型所有的beanstatic <T> TgetSingleBeanByType(Class<T> clazz) 根据class 类型获取beanvoidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
字段详细资料
-
applicationContext
protected static org.springframework.context.ApplicationContext applicationContextspring bean上下文
-
-
构造器详细资料
-
SpringBeanService
public SpringBeanService()
-
-
方法详细资料
-
getBeanByName
public static <T> T getBeanByName(String name, Class<T> clazz) throws org.springframework.beans.BeansException 获取bean实例- 抛出:
org.springframework.beans.BeansException
-
getBeanByName
获取bean实例- 抛出:
org.springframework.beans.BeansException
-
getBeansOfType
获取此类型所有的bean- 参数:
clazz-- 返回:
- 抛出:
org.springframework.beans.BeansException
-
getSingleBeanByType
根据class 类型获取bean- 参数:
clazz-- 返回:
- 抛出:
org.springframework.beans.BeansException- 当有继承或者接口时(多个实现类)getBean(clazz)会报错 所以通过class name比较来获取唯一那个beanException
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - 指定者:
setApplicationContext在接口中org.springframework.context.ApplicationContextAware- 抛出:
org.springframework.beans.BeansException
-