我正在尝试将Apache CXF与Spring集成以创建RESTful Web服务.但是在部署应用程序时,我得到以下异常.
SEVERE: Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://cxf.apache.org/jaxrs]
Offending resource: ServletContext resource [/WEB-INF/beans.xml]
Run Code Online (Sandbox Code Playgroud)
这是我的beans.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<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" />
<jaxrs:server id="empservice" address="/">
<jaxrs:serviceBeans>
<ref bean="empservice"/>
</jaxrs:serviceBeans>
</jaxrs:server>
</beans>
Run Code Online (Sandbox Code Playgroud)
我的pom.xml是
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.maventest</groupId>
<artifactId>Lab</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>Lab Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<javac.version>1.6</javac.version>
<spring.version>3.0.3.RELEASE</spring.version>
<junit.version>4.5</junit.version>
<servlet-api.version>2.5.0</servlet-api.version>
<cxf.version>2.4.0</cxf.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version> …Run Code Online (Sandbox Code Playgroud)