|  |  |  | 
|---|
|  |  |  | import org.springframework.beans.factory.DisposableBean; | 
|---|
|  |  |  | import org.springframework.context.ApplicationContext; | 
|---|
|  |  |  | import org.springframework.context.ApplicationContextAware; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author wzy | 
|---|
|  |  |  | 
|---|
|  |  |  | * @email wangdoubleone@gmail.com | 
|---|
|  |  |  | * @Version V1.0 | 
|---|
|  |  |  | **/ | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | public class SpringContextHolder implements ApplicationContextAware, DisposableBean { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if (SpringContextHolder.applicationContext != null) { | 
|---|
|  |  |  | log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | log.info("====================="); | 
|---|
|  |  |  | SpringContextHolder.applicationContext = applicationContext; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|