【发布时间】:2018-02-14 13:53:16
【问题描述】:
早安,
我正在使用 apache cxf 和 spring boot 来构建 Web 服务,但是当我尝试调用端点时,它给了我这个错误:
WARN 15936 --- [nio-8080-exec-4] o.a.cxf.phase.PhaseInterceptorChain : Application {
endpointMethod has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: org/apache/cxf/jaxb/JAXBToStringStyle
[...]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
Caused by: java.lang.NoClassDefFoundError: org/apache/cxf/jaxb/JAXBToStringStyle
这是我对网络服务的配置:
@Configuration
public class WebServiceConfig {
@Bean
public org.springframework.boot.web.servlet.ServletRegistrationBean cxfServlet() {
return new org.springframework.boot.web.servlet.ServletRegistrationBean(new CXFServlet(), "/cxf-api/*");
}
@Bean(name = Bus.DEFAULT_BUS_ID)
public SpringBus springBus() {
return new SpringBus();
}
@Bean
public Conc2MGPService conc2MGPService() {
return new RegistrationServiceEndpoint();
}
@Bean
public Endpoint endpoint() {
EndpointImpl endpoint = new EndpointImpl(springBus(), concessionario2MGPService());
endpoint.publish("/registration_endpoint");
return endpoint;
}
这里是我的 POM:
<project ...">
<groupId>com.me.justin</groupId>
<artifactId>registration-gateway-app</artifactId>
<packaging>war</packaging>
<name>registration-gateway-app</name>
<description>Demo project for Spring Boot</description>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jersey</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
</dependency>
<dependency>
<groupId>it.justin</groupId>
<artifactId>justin-soap-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-databinding-jaxb</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
我错过了什么? 我在这里所做的是对请求传递的对象的简单日志。
@Override
public RegisterContract(RegisterContractRequest registerContractRequest) {
log.info("RegisterContract" + registerContractRequest);
return null;
}
我认为我的 POM 中缺少某些东西,但我不知道是什么。
【问题讨论】:
-
您将依赖项定义为运行时,例如它将由容器在运行时提供。如果您使用的是嵌入式容器,或者它不是您部署到的容器的一部分,则需要编译该依赖项。
标签: java maven spring-boot cxf jax-ws