Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第三十二章:如何获取SpringBoot项目的applicationContext对象 - 恒宇少年De成长之路 #43

Open
hengboy opened this issue Mar 4, 2019 · 1 comment

Comments

@hengboy
Copy link
Owner

hengboy commented Mar 4, 2019

http://blog.yuqiyu.com/spring-boot-chapter32.html

ApplicationContext对象是Spring开源框架的上下文对象实例,在项目运行时自动装载Handler内的所有信息到内存。传统的获取方式有很多种,不过随着Spring版本的不断迭代,官方也慢慢的不建议使用部分方式。下面我简单介绍一种Spring官方推荐使用的方式!

@l0n9er
Copy link

l0n9er commented Apr 26, 2019

private static ApplicationContext applicationContext;
@OverRide
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
静态变量引用问题
@OverRide
public void setApplicationContext(ApplicationContext application) throws BeansException {
applicationContext = application;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants