zoukankan      html  css  js  c++  java
  • spring+cxf No bean named 'cxf' available

    最近项目中需要用到webservice,在spring中集成cxf时一直报错:

    严重: StandardWrapper.Throwable org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'cxf' available at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1213) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1086) at org.apache.cxf.transport.servlet.CXFServlet.loadBus(CXFServlet.java:80)

    网上给出的最多的解决方案是:

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

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

    另外就是说spring版本和cxf版本不匹配等。

    试了很多种方案都不行,最后尝试修改配置文件解决了;

    修改前:

    web.xml

    <servlet>
    		<servlet-name>springmvc</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value>classpath:springmvc-servlet.xml,classpath:springContext-cxf.xml</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    </servlet>

    修改方案:将springContext-cxf.xml配置文件导入到springmvc-servlet.xml文件中

    修改后代码

    web.xml

    <servlet>
    		<servlet-name>springmvc</servlet-name>
    		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    		<init-param>
    			<param-name>contextConfigLocation</param-name>
    			<param-value>classpath:springmvc-servlet.xml</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    </servlet>
    

    springmvc-servlet.xml

     <!-- 导入webservice接口配置文件 -->
        <import resource="classpath:applicationContext-cxf.xml" />
    </beans> 

    问题解决,我用的是spring5.0+cxf 3.1,亲测这个不存在版本不匹配问题。

  • 相关阅读:
    C++类型前置声明
    Qt 引用头文件 QT_BEGIN_NAMESPACE QT_END_NAMESPACE
    Qt emit的使用
    特定于类的内存管理---《C++必知必会》 条款36
    C++深入理解虚函数
    使用网页预加载顶部进度条
    简单读取 properties文件
    win2012r2 关闭中英文悬浮小方框显示
    bootstrap的Alerts中 可以放置p标签 设置 align="center" 用来设置文本居中
    char和String 在jsp java代码中与jstl代码中的区别
  • 原文地址:https://www.cnblogs.com/xxjcai/p/11828493.html
Copyright © 2011-2022 走看看