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


		springmvc
		org.springframework.web.servlet.DispatcherServlet
		
			contextConfigLocation
			classpath:springmvc-servlet.xml,classpath:springContext-cxf.xml
		
		1

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

修改后代码

web.xml


		springmvc
		org.springframework.web.servlet.DispatcherServlet
		
			contextConfigLocation
			classpath:springmvc-servlet.xml
		
		1

springmvc-servlet.xml

 
    
 

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

 

 

你可能感兴趣的:(spring+cxf No bean named 'cxf' available)