我正在尝试遵循spring-boot的te指南,以便运行SOAP服务器。问题是它抛出了这个错误:
2016-09-19 09:43:39.797 WARN 8668 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultMethodEndpointAdapter' defined in class path resource [org/springframework/ws/config/annotation/DelegatingWsConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter]: Factory method 'defaultMethodEndpointAdapter' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter.setCustomMethodArgumentResolvers(Ljava/util/List;)V
我的ws配置bean文件是:
@EnableWs
@Configuration
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/*");
}
@Bean(name = "expedientes")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema expedienteSchema) {
DefaultWsdl11Definition wsdl11Definition = new DefaultWsdl11Definition();
wsdl11Definition.setPortTypeName("ExpedientesPort");
wsdl11Definition.setLocationUri("/ws");
wsdl11Definition.setTargetNamespace("http://localhost/ws");
wsdl11Definition.setSchema(expedienteSchema);
return wsdl11Definition;
}
@Bean
public XsdSchema expedienteSchema() {
return new SimpleXsdSchema(new ClassPathResource("Expedientes.xsd"));
}
}
它应该自动配置其余的,所以我无法理解这个错误。
我在整个网站上浏览了一些相关的错误,但没有任何帮助。 请问任何提示?
答案 0 :(得分:1)
您收到的错误是
java.lang.NoSuchMethodError: org.springframework.ws.server.endpoint.adapter.DefaultMethodEndpointAdapter.setCustomMethodArgumentResolvers(Ljava/util/List;)V
类“DefaultMethodEndpointAdapter”是spring-ws-core jar文件的一部分。方法“DefaultMethodEndpointAdapter.setCustomMethodArgumentResolvers(List customMethodArgumentResolvers)”自spring-ws-core-2.2.0.RELEASE.jar开始提供。以下是使用Spring Boot 1.4.0的WS项目所需的依赖项,根据春季指南https://spring.io/guides/gs/producing-web-service/,它将下载最新的spring-ws-core-2.3.0.RELEASE.jar。请检查您在pom.xml中使用的依赖项和版本。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-ws</artifactId>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
</dependency>
</dependencies>