本文介绍了2.4.0中的Apache CXF RS扩展问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache CXF 2.4.0版。我正在尝试创建一个Restful服务。

I'm using Apache CXF version 2.4.0. I'm trying to create a Restful service.

以下示例在2.3.4中可用,但在2.4.0中不可用。在bean配置文件中应该做些什么?

The below example works in 2.3.4 but does not work in 2.4.0. What should I do different in beans config file?

当我在bean配置文件中包含以下xml行时。

When I include the below xml line in my bean config file.

<import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" /> 

我收到以下stacktrace错误:

I get the following stacktrace error:

违规资源:ServletContext
资源[/WEB-INF/beans.xml] ;嵌套的
异常是
org.springframework.beans.factory.BeanDefinitionStoreException:

Offending resource: ServletContext resource [/WEB-INF/beans.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException:

IOException从
类路径资源$ b解析XML文档$ b [META-INF / cxf / cxf-extension-jaxrs-binding.xml];
嵌套异常是
java.io.FileNotFoundException:类
路径资源
[META-INF / cxf / cxf-extension-jaxrs-binding.xml]
无法因为

处不存在而被打开org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)

IOException parsing XML document from class path resource [META-INF/cxf/cxf-extension-jaxrs-binding.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/cxf/cxf-extension-jaxrs-binding.xml] cannot be opened because it does not exist at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)

我的POM依赖项如下。这将适用于2.3.4,但不适用于2.4.0。有什么建议么? xml扩展行是否已弃用或包含在另一个jar中?

My POM dependency is below. This will work for 2.3.4 but not for 2.4.0. Any suggestions? Is that xml extension line deprecated or included in another jar?

    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-bundle-jaxrs</artifactId>
        <version>2.3.4</version>
        <exclusions>
            <exclusion>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-server</artifactId>
            </exclusion>
        </exclusions>
    </dependency>


推荐答案

不再需要。使用2.4.x,不再需要大多数META-INF / cxf文件,可以将其删除。确实,仅需要一个cxf.xml。

It's no longer needed. With 2.4.x, most of the META-INF/cxf files are no longer needed and can be removed. Really, the cxf.xml one is the only one needed.

这篇关于2.4.0中的Apache CXF RS扩展问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 19:49