在https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html 11.1中有一个示例:
public class MyWebApplicationInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletCxt) {
// Load Spring web application configuration
AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext();
ac.register(AppConfig.class);
ac.refresh();
...
然后在第11.4章中有另一个示例,但是没有ac.refresh();
创建上下文后立即刷新上下文有什么好处?