Java 官方示例中的Spring setApplicationContext问题
我正在尝试运行Spring的入门指南之一(使用Java 官方示例中的Spring setApplicationContext问题,java,spring,Java,Spring,我正在尝试运行Spring的入门指南之一(使用Maven),但我在生成Web服务时遇到了问题 此处的指南链接 出于某种原因,我不断得到错误: The method setApplicationContext(ApplicationContext) is undefined for the type MessageDispatcherServlet 关于以下代码: public class WebServiceConfig extends WsConfigurerAdapter { @B
Maven
),但我在生成Web服务时遇到了问题
此处的指南链接
出于某种原因,我不断得到错误:
The method setApplicationContext(ApplicationContext) is undefined for the type MessageDispatcherServlet
关于以下代码:
public class WebServiceConfig extends WsConfigurerAdapter {
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
我检查了API引用,并且MessageDispatcherServlet
应该从FrameworkServlet
继承setApplicationContext
,但由于某些原因它不在那里
非常感谢您的帮助。看起来您的类路径中有一个错误版本的SpringWeb
。
4.0版中引入了方法setApplicationContext
查看官方的看起来您的类路径中有一个错误版本的SpringWeb
。
4.0版中引入了方法setApplicationContext
查看官方我们在谈论哪个Spring版本?我们在谈论哪个Spring版本?谢谢,这是正确的。你能告诉我我应该怎么做才能让Spring3正常工作吗?你必须调用MessageDispatcherServlet servlet=newmessagedispatcherservlet(applicationContext)代码>我想。谢谢,这是正确的。你能告诉我我应该怎么做才能让Spring3正常工作吗?你必须调用MessageDispatcherServlet servlet=newmessagedispatcherservlet(applicationContext)代码>我想。