ssm框架整合cxf
时间: 2023-07-01 18:23:30 浏览: 117
将SSM框架整合CXF的步骤如下:
1. 在pom.xml文件中添加CXF和JAX-WS的依赖。
```xml
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-core</artifactId>
<version>3.2.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.2.6</version>
</dependency>
```
2. 在Spring的配置文件中加入CXF的配置。
```xml
<jaxws:endpoint id="userService" implementor="com.example.service.UserService" address="/userService">
<jaxws:features>
<bean class="org.apache.cxf.feature.LoggingFeature"/>
</jaxws:features>
</jaxws:endpoint>
```
3. 在Spring的配置文件中加入CXF和SSM框架的整合配置。
```xml
<bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus">
<property name="cxfConfigLocation" value="classpath:META-INF/cxf/cxf.xml"/>
</bean>
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:config.properties"/>
</bean>
<bean id="userService" class="org.apache.cxf.jaxws.EndpointImpl">
<property name="bus" ref="cxf"/>
<property name="endpointName" value="tns:UserServicePort"/>
<property name="serviceName" value="tns:UserService"/>
<property name="implementor" ref="userServiceImpl"/>
<property name="address" value="${service.url}"/>
</bean>
```
4. 在web.xml文件中加入CXF的servlet配置。
```xml
<servlet>
<servlet-name>CXFServlet</servlet-name>
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
<init-param>
<param-name>config-location</param-name>
<param-value>/WEB-INF/cxf-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
```
以上就是SSM框架整合CXF的步骤,希望能对你有所帮助!
阅读全文