gpt4 book ai didi

java - org/apache/cxf/jaxb/JAXBToStringStyle 上的 NoClassDefFoundError

转载 作者:行者123 更新时间:2023-11-30 06:18:00 27 4
gpt4 key购买 nike

美好的一天,

我正在使用 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 中缺少某些内容,但我不知道是什么。

最佳答案

将此依赖项添加到您的 pom.xml 中。

 <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>

关于java - org/apache/cxf/jaxb/JAXBToStringStyle 上的 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48788870/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com