使用spring-ws
做基于SOAP的应用程序。但是,如果我添加此以下依赖(从春季引导教程https://spring.io/guides/gs/producing-web-service/锯),分离Spring-WS和Spring-Webmvc
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
它还引入spring-webmvc
。如果我排除它,
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</exclusion>
</exclusions>
我在这里得到错误;
@Bean
public ServletRegistrationBean messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
//ERROR Here
//cannot find symbol
//symbol: method setApplicationContext(ApplicationContext)
//location: variable servlet of type MessageDispatcherServlet
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean(servlet, "/ws/*");
}
它们是不是分开模块?为什么我必须使用spring-webmvc
,当我只需要spring-ws
?
我在这里不明白?
请详细说明。 (1)你能不能排除你的屁股? (2)您可以发布实际错误(使用堆栈跟踪)。 – Tim
@Tim:这是编译时错误。在IDE中显示。并更新了问题。 – Raj
在这种情况下,您包含的错误消息显然不是直接复制的。该消息会说更像“没有方法setApplicationContext上....”请逐字粘贴。 – Tim