@Component public class ConfigurationUtil extends Object implements org.springframework.context.ApplicationContextAware
Constructor and Description |
---|
ConfigurationUtil() |
Modifier and Type | Method and Description |
---|---|
org.springframework.context.ApplicationContext |
getApplicationContext()
获得spring上下文
|
Object |
getBean(String name)
获取bean
|
String |
getConfig(String key)
获取配置文件的值,兼容传统spring项目和springboot项目
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
实现ApplicationContextAware接口的回调方法,设置上下文环境
|
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
setApplicationContext
in interface org.springframework.context.ApplicationContextAware
public org.springframework.context.ApplicationContext getApplicationContext()
public Object getBean(String name) throws org.springframework.beans.BeansException
name
- service注解方式name为小驼峰格式org.springframework.beans.BeansException
Copyright © 2021. All rights reserved.