【发布时间】:2018-03-02 14:43:45
【问题描述】:
所以我刚刚将我的 Spring Boot Web 应用升级到 2.0.0,在我的主应用程序类中,我有这个方法:
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
WebApplicationContext rootAppContext = createRootApplicationContext(servletContext);
if (rootAppContext != null) {
servletContext.addListener(new RequestContextListener());
}
else {
logger.debug("No ContextLoaderListener registered");
}
}
但是现在我得到一个编译错误:
The method addListener(RequestContextListener) is undefined for the type ServletContext
奇怪的是 ServletContext 是问题所在,而不是 Spring boot。它不再有任何 add* 方法。 Spring5/Boot2 是否升级了 servlet 规范,以及 现在这样做的正确方法是什么?
【问题讨论】:
标签: spring-boot