无法找到命名空间的NamespaceHandler [http://www.springframework.org/schema/context]

时间:2013-06-14 00:39:47

标签: java web-services spring jax-ws

当我尝试运行我的应用程序时,我总是收到错误:无法找到命名空间的NamespaceHandler [http://www.springframework.org/schema/context]。我不知道什么是错的。 所以这是我的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" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:ws="http://jax-ws.dev.java.net/spring/core"
    xmlns:wss="http://jax-ws.dev.java.net/spring/servlet"
    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://jax-ws.dev.java.net/spring/core http://jax-ws.dev.java.net/spring/core.xsd
            http://jax-ws.dev.java.net/spring/servlet http://jax-ws.dev.java.net/spring/servlet.xsd">

    <import resource="classpath:datasource.xml" />

    <!-- Register @Autowired annotation -->
    <bean
        class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor" />

    <context:component-scan base-package="pl.edu.pk" />

    <wss:binding url="/StudentService.ws">
        <wss:service>
            <ws:service bean="#studentServiceEndpoint"></ws:service>
        </wss:service>
    </wss:binding>

    <bean id="studentServiceEndpoint" class="pl.edu.pk.webservices.StudentServiceEndpoint" />

</beans>

这是我的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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.madbit.hibernate</groupId>
    <artifactId>spring-hibernate4</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <properties>
        <spring.version>3.2.2.RELEASE</spring.version>
    </properties>
        <repositories>
            <repository>
                <id>java.net</id>
                <url>http://download.java.net/maven/2</url>
            </repository>
        </repositories>
    <dependencies>
        <!-- Spring framework -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency> <!-- Used for Hibernate4 LocalSessionFactoryBean -->
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <!-- AOP dependency -->
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2.2</version>
        </dependency>

        <!-- Persistence Management -->
        <dependency> <!-- Apache BasicDataSource -->
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.2.2</version>
        </dependency>

        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.1-901.jdbc4</version>
        </dependency>

        <dependency> <!-- Hibernate -->
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>4.1.3.Final</version>
        </dependency>

        <dependency>
            <groupId>org.apache.xbean</groupId>
            <artifactId>xbean-spring</artifactId>
            <version>2.8</version>
            <exclusions>
                <exclusion>
                    <artifactId>spring</artifactId>
                    <groupId>org.springframework</groupId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.3</version>
        </dependency>


            <!-- Exclude some unnecessary libraries -->
            <dependency>
                <groupId>org.jvnet.jax-ws-commons.spring</groupId>
                <artifactId>jaxws-spring</artifactId>
                <version>1.8</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-core</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-context</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.sun.xml.stream.buffer</groupId>
                        <artifactId>streambuffer</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.jvnet.staxex</groupId>
                        <artifactId>stax-ex</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>

        </dependencies>
        <build>
            <finalName>web services</finalName>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.1</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                    </configuration>
                </plugin>
            </plugins>
        </build>
</project>

我找不到什么问题; /它应该是库问题但是在哪里?

1 个答案:

答案 0 :(得分:1)

这通常是因为类路径中缺少spring-context.jar。尝试将spring-context依赖项添加到pom.xml

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>${spring.version}</version>
</dependency>