cxf配置

先记录一下,后期补充配置原因

原先的spring3.X(struts2)的时候配置cxf2.x没问题,基本就是在context.xml中加入

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

这三个文件即可。

后期框架为springmvc4.3(mybatis),这时候cxf的版本已经迭代到3.2.4了,我们查看一下这个最新版本的编译发现是jdk8了,部署在我们的jdk7下回报错,所以讲版本,目前我用的是

spring4.3+mybatis3.4+cxf3.1.6

主要说一配置文件的事情(spring-mybatis.xml,spring-mvc.xml,cxf-servlet.xml,web.xml)

cxf-servlet.xml文件的位置要放到应用上下文的加载位置,不能放到servlet的加载位置,也就是说

1、可以放到咱们的WEB-INF下(编译后类的根目录,在webapp下)

2、可以放到web.xml下的<context-param>,如:

<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/spring-mybatis.xml,classpath:spring/cxf-servlet.xml</param-value>
</context-param>

3、可以直接在spring-mybatis.xml中import一下,这样应用启动时候,在应用环境加载mybatis的时候,它一起加载

<import resource="cxf-servlet.xml"/>

总而言之,保证在应用的加载路径下即可

我猜这样的原因,是cxf的一些配置调用是全局的上下文而不是servlet域的(每个servlet都有自己的上下文,他们共享javabean),这个后期考证后在这里补上
发一下cxf的maven和配置:

maven:

<!-- cxf begin -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.6</version>
</dependency>
<!-- cxf end -->

cxf-servlet.xml内容:

<?xml version="1.0" encoding="UTF-8"?>
<!-- START SNIPPET: beans -->
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:endpoint ></jaxws:endpoint>
</beans>