Java 官方示例中的Spring setApplicationContext问题

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

我正在尝试运行Spring的入门指南之一(使用
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)我想。