java.lang.ClassNotFoundException:org.springframework.web.servlet.DispatcherServlet [英] java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

查看:95
本文介绍了java.lang.ClassNotFoundException:org.springframework.web.servlet.DispatcherServlet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 spring 3.1.0.RELEASE ,我的servlet容器是 tomcat 7 ,而我的IDE是 eclipse indigo spring-webmvc-3.1.0.RELEASE.jar 罐,其中包含 DispatcherServlet 存在于lib文件夹中,但是在运行该应用程序时,出现了异常:

i am using spring 3.1.0.RELEASE, and my servlet container is tomcat 7 and my IDE is eclipse indigo and the jar spring-webmvc-3.1.0.RELEASE.jar which contains the DispatcherServlet exists in the lib folder, and yet when running the application, i am getting the exception:

java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1678)
    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1523)
    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:525)
    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:507)
    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:126)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1099)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1043)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4957)
    at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5284)
    at org.apache.catalina.core.StandardContext$3.call(StandardContext.java:5279)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)

请告知为什么我会收到此异常,以及如何解决它.

please advise why i am getting this exception, and how to fix it.

以下是我的配置文件:

1- .springBeans:

<?xml version="1.0" encoding="UTF-8"?>
<beansProjectDescription>
    <version>1</version>
    <pluginVersion><![CDATA[2.9.0.201203011806-RELEASE]]></pluginVersion>
    <configSuffixes>
        <configSuffix><![CDATA[xml]]></configSuffix>
    </configSuffixes>
    <enableImports><![CDATA[false]]></enableImports>
    <configs>
        <config>src/main/webapp/WEB-INF/checkout-servlet.xml</config>
    </configs>
    <configSets>
    </configSets>
</beansProjectDescription>

2- web.xml:

<web-app>
  <display-name>Checkout</display-name>

  <servlet>
    <servlet-name>checkout</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>checkout</servlet-name>
    <url-pattern>*.action</url-pattern>
  </servlet-mapping>

</web-app>

3- checkout-servlet.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"
    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-3.1.xsd">

    <context:component-scan base-package="com.myapp"/>

    <bean id="myService" class="com.myapp.MyService"/>

</beans>

当尝试访问应用程序中的任何页面时,也会出现异常:

also when trying to access any page in the application, i get the exception:

HTTP Status 404 - Servlet checkout is not available

type Status report

message Servlet checkout is not available

description The requested resource (Servlet checkout is not available) is not available.
Apache Tomcat/7.0.22

推荐答案

我发现在部署程序集中,存在以下条目:

i found that in the deployment assembly, there was the entry:

[persisted container] org.maven.ide.eclipse.maven2_classpath_container

我删除了它,并添加了maven dependencies条目,现在可以正常使用了.

i removed it, and added the maven dependencies entry, and it works fine now.

这篇关于java.lang.ClassNotFoundException:org.springframework.web.servlet.DispatcherServlet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆