mirror of https://gitee.com/y_project/RuoYi.git
添加获取当前的环境配置方法
parent
277d42c12b
commit
43ce484f36
|
@ -1,20 +1,23 @@
|
||||||
package com.ruoyi.common.utils.spring;
|
package com.ruoyi.common.utils.spring;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
|
||||||
import org.springframework.aop.framework.AopContext;
|
import org.springframework.aop.framework.AopContext;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* spring工具类 方便在非spring管理环境中获取bean
|
* spring工具类 方便在非spring管理环境中获取bean
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware
|
public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware
|
||||||
{
|
{
|
||||||
/** Spring应用上下文环境 */
|
/** Spring应用上下文环境 */
|
||||||
private static ConfigurableListableBeanFactory beanFactory;
|
private static ConfigurableListableBeanFactory beanFactory;
|
||||||
|
@ -22,13 +25,13 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
|
||||||
private static ApplicationContext applicationContext;
|
private static ApplicationContext applicationContext;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
|
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException
|
||||||
{
|
{
|
||||||
SpringUtils.beanFactory = beanFactory;
|
SpringUtils.beanFactory = beanFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException
|
||||||
{
|
{
|
||||||
SpringUtils.applicationContext = applicationContext;
|
SpringUtils.applicationContext = applicationContext;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue