美好的一天,
我正在使用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
以下是我对webservice的配置:
@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中缺少某些东西,但我无法弄清楚是什么。
答案 0 :(得分:0)
将此依赖项添加到您的pom。
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-bundle</artifactId>
<version>2.7.18</version>
</dependency>
作为旁注,不推荐使用此jar,尝试更新您的依赖项。以上jar的新版本如下。 (但为了使用它,您已更新相关的依赖项)
<groupId>org.apache.cxf.xjc-utils</groupId>
<artifactId>cxf-xjc-runtime</artifactId>
<version>3.2.1</version>