Spring MVC中未找到类异常

时间:2014-06-10 04:17:55

标签: java spring maven spring-mvc

我收到此异常但是当我查看我的MAVEN DEPENDENCIES文件夹时,我可以看到pom.xml正确下载了所有类。

            Jun 10, 2014 9:43:49 AM org.apache.catalina.core.AprLifecycleListener init
            INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jdk1.8.0_05\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jdk1.8.0_05/bin/../jre/bin/server;C:/Program Files/Java/jdk1.8.0_05/bin/../jre/bin;C:/Program Files/Java/jdk1.8.0_05/bin/../jre/lib/amd64;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Program Files\Java\jdk1.8.0_05\bin;C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files (x86)\Common Files\Microsoft Shared\Microsoft Online 

Services;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;d:\Program Files (x86)\ZipGenius 6\;.;D:\Program Files\TortoiseSVN\bin;.;C:\ANT;.;E:\Software\BB 10 IDE\bbndk\sdkinstall.bat;.;E:\ADT_BUNDLE_SETUP\adt-bundle-windows-x86-20130729\sdk\platform-tools\;.;D:\BB7InstallationFolder\webworks;.;E:\ADT_BUNDLE_SETUP\adt-bundle-windows-x86-20130729\sdk\tools;.;D:\Tomcat 7.0\bin;.;C:\Users\sandhiya.sankara\AppData\Roaming\npm;;D:\eclipse;;.
            Jun 10, 2014 9:43:49 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
            WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:HelloWorld' did not find a matching property.
            Jun 10, 2014 9:43:49 AM org.apache.coyote.AbstractProtocol init
            INFO: Initializing ProtocolHandler ["http-bio-8080"]
            Jun 10, 2014 9:43:49 AM org.apache.coyote.AbstractProtocol init
            INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
            Jun 10, 2014 9:43:49 AM org.apache.catalina.startup.Catalina load
            INFO: Initialization processed in 628 ms
            Jun 10, 2014 9:43:50 AM org.apache.catalina.core.StandardService startInternal
            INFO: Starting service Catalina
            Jun 10, 2014 9:43:50 AM org.apache.catalina.core.StandardEngine startInternal
            INFO: Starting Servlet Engine: Apache Tomcat/7.0.54
            Jun 10, 2014 9:43:50 AM org.apache.catalina.core.StandardContext listenerStart
            SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
            java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
                at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
                at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
                at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:529)
                at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:511)
                at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:139)
                at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4888)
                at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
                at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
                at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
                at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
                at java.util.concurrent.FutureTask.run(FutureTask.java:266)
                at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
                at java.lang.Thread.run(Thread.java:745)

            Jun 10, 2014 9:43:50 AM org.apache.catalina.core.StandardContext listenerStart
            SEVERE: Skipped installing application listeners due to previous error(s)
            Jun 10, 2014 9:43:50 AM org.apache.catalina.core.StandardContext startInternal
            SEVERE: Error listenerStart
            Jun 10, 2014 9:43:50 AM org.apache.catalina.core.StandardContext startInternal
            SEVERE: Context [/mvc] startup failed due to previous errors
            Jun 10, 2014 9:43:50 AM org.apache.coyote.AbstractProtocol start
            INFO: Starting ProtocolHandler ["http-bio-8080"]
            Jun 10, 2014 9:43:50 AM org.apache.coyote.AbstractProtocol start
            INFO: Starting ProtocolHandler ["ajp-bio-8009"]
            Jun 10, 2014 9:43:50 AM org.apache.catalina.startup.Catalina start
            INFO: Server startup in 575 ms

这是我的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>HelloWorld</groupId>
      <artifactId>HelloWorld</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>war</packaging>

      <name>HelloWorld</name>
      <url>http://maven.apache.org</url>

      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring.version>3.0.5.RELEASE</spring.version>
      </properties>

      <dependencies>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>3.8.1</version>
          <scope>test</scope>
        </dependency>

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

            <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>
      </dependencies>
    </project>

我已经提到堆栈溢出提供的所有其他答案类似的问题。没有任何帮助我。我的项目也成功建成。

3 个答案:

答案 0 :(得分:1)

我删除了maven存储库文件夹.repository

并更新了eclipse中的所有依赖项,然后解决了这个问题

答案 1 :(得分:0)

web.xml

中使用以下内容
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/context.xml</param-value>
    </context-param>

    <!-- Spring Context Listener -->
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>

答案 2 :(得分:0)

我删除了“target”目录中的war文件,重新启动了eclipse,然后在maven中进行了全新安装。这解决了我的问题。