spring集成webservice框架cxf,访问报错service not found
来源:互联网 发布:java io读取文件 编辑:程序博客网 时间:2024/06/05 04:15
这是因为我把cxf的配置文件spring-mvc的配置文件写在同一个xml里,Spring MVC是通过DispatcherServlet来加载Spring配置文件的,因此不需要在web.xml中配置ContextLoaderListener。但是CXF却需要通过ContextLoaderListener来加载Spring。这样就产生了一个矛盾,如果不配置ContextLoaderListener,CXF就无法正常使用。但如果配置ContextLoaderListener,又会造成Spring的重复加载(DispatcherServlet一次,ContextLoaderListener一次) ,后来就分开配置两个spring-mvc.xml和spring-cxf.xml
spring-cxf.xml配置文件:
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 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://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <import resource="classpath:META-INF/cxf/cxf.xml"/> <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> <!-- 自动扫描webService --> <context:component-scan base-package="com.yingjun.ssm.cxf"/> <!-- 定义webService的发布接口 --> <jaxws:endpoint implementor="#helloWorld" address="/helloWorld"/></beans>
spring-mvc.xml配置文件
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- 激活组件扫描功能,扫描aop的相关组件组件 --> <context:component-scan base-package="com.yingjun.ssm.aop"/> <!-- 启动对@AspectJ注解的支持 --> <aop:aspectj-autoproxy proxy-target-class="true" /> <!--简化配置: 1、自动注册DefaultAnnotationHandlerMapping,AnnotationMethodHandlerAdapter 2、提供一系列:数据绑定,数字和日期的format,@NumberFormat,@DataTimeFormat,xml,json默认读写支持 --> <mvc:annotation-driven/> <!--静态资源默认servlet配置 1、加入对静态资源的处理:js,css,gif,png 2、允许使用"/"做整体映射 --> <mvc:default-servlet-handler/> <!--配置JSP 显示ViewResolver--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <!--扫描web相关的controller--> <context:component-scan base-package="com.yingjun.ssm.web"/> <!--全局异常捕捉 --> <bean class="com.yingjun.ssm.exception.GlobalExceptionResolver" /></beans>
由于系统中还有其他的上下文bean,就把spring-cxf.xml导入到application-context.xml中
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">... <import resource="spring-cxf.xml"/></beans>
web.xml修改好的配置如下:
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/application-context.xml</param-value></context-param><listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></listener><!--配置DispatcherServlet --><servlet> <servlet-name>spring-dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <!-- 配置SpringMVC需要加载的配置文件 spring-xxx.xml --> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring/spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup></servlet><servlet-mapping> <servlet-name>spring-dispatcher</servlet-name> <!--默认匹配所有的请求 --> <url-pattern>/</url-pattern></servlet-mapping>
阅读全文
0 0
- spring集成webservice框架cxf,访问报错service not found
- 在spring中集成webservice 框架 CXF
- CXF webService集成spring
- cxf框架和spring框架集成的Webservice例子
- 基于Maven环境进行Spring集成CXF WebService框架
- 基于Maven在Spring中集成CXF Web Service框架
- spring集成cxf发布webservice
- Maven 集成CXF Webservice,Spring
- CXF集成SPRING的WEBSERVICE
- cxf+web service(四)cxf+spring集成
- CXF webservice报错
- Spring 部署CXF 框架--WebService
- WebService CXF整合Spring框架
- Spring整合webservice CXF框架
- Spring 集成CXF框架发布Webservice服务 和 使用jdk生成Webservice clinet
- CXF框架集成到Spring
- spring mybatis集成报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- Maven项目集成cxf框架发布WebService
- 常见框架中的单例、多例与线程安全性总结
- 22. Generate Parentheses
- DTD--eclipse中设置XML文件自动补全的方法步骤
- js自适应rem -- 主要适用于移动端
- 第一篇博客
- spring集成webservice框架cxf,访问报错service not found
- clippingNode新手引导
- javascript获取地址栏各字段方法
- Mysql怎么同步两个不同库的不同表以及部分字段
- linux小工具安装
- 打包生成桌台二维码
- 使用IDEA新建一个Spring Boot项目
- 在Qt中移植VPU编解码程序时遇到的问题
- C语言小碎片七