简体   繁体   English

找不到org.springframework.web.servlet.DispatcherServlet

[英]org.springframework.web.servlet.DispatcherServlet Not Found

Okay this has been bugging the hell out of me and I've looked around, and every other thread says go to deployment assembly. 好的,这一直困扰着我,我环顾四周,其他所有线程都说要去部署程序集。 Problem is when I go there, theres no 'maven depencies' to click on. 问题是当我去那里时,没有“专家依赖”可以单击。

Like in this thread: org.springframework.web.servlet.DispatcherServlet not found with VMWare vFabric tc Server and maven dispatcherservlet-not-found-with-vmware-vfabric 就像在此线程中一样:在VMWare vFabric tc Server和Maven dispatcherservlet中找不到org.springframework.web.servlet.DispatcherServlet,与vmware-vfabric一起找不到

I get to that screen and theres no maven depencies to click. 我进入该屏幕,没有可点击的专家意见。

My web.xml is: 我的web.xml是:

<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>Spring MVC Application</display-name>

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

<servlet-mapping>
  <servlet-name>SpringMVC</servlet-name>
  <url-pattern>/</url-pattern>
</servlet-mapping>

</web-app>

and the -servlet.xml 和-servlet.xml

   xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
 http://www.springframework.org/schema/beans     
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

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

<bean     class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="prefix" value="/WEB-INF/jsp/" />
  <property name="suffix" value=".jsp" />
</bean>

</beans>

Any help is appreciated. 任何帮助表示赞赏。 I'm using STS tools/Eclipse. 我正在使用STS工具/ Eclipse。

heres the pom. 这是绒球。 all the jars are in the folder java resources/libraries/maven dependecies 所有的罐子都在java资源/库/ maven依赖文件夹中

     <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>SpringMVC</groupId>
 <artifactId>SpringMVC</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>war</packaging>
  <name>SpringMVC</name>

<properties>
    <java.version>1.8</java.version>
</properties>

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.2.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter</artifactId>
        </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
    </dependency>
    <dependency>
        <groupId>com.jayway.jsonpath</groupId>
        <artifactId>json-path</artifactId>
        <version>2.2.0</version>
    </dependency>
    <dependency>
     <groupId>org.json</groupId>
  <artifactId>json</artifactId>
  <version>20090211</version>
   </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.8.5</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <version>1.3.2.RELEASE</version>
        <scope>test</scope>
    </dependency>
  </dependencies>

 <build>
<sourceDirectory>src</sourceDirectory>
<resources>
  <resource>
    <directory>src</directory>
    <excludes>
      <exclude>**/*.java</exclude>
    </excludes>
  </resource>
</resources>
<plugins>
  <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.5.1</version>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
    </configuration>
    </plugin>
    <plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>3.0.0</version>
    </plugin>
   </plugins>
  </build>
</project>

Exception is: 例外是:

ava.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1892)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1735)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:504)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:486)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:113)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1133)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1072)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5368)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5660)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1571)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1561)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

EDIT: I got it to compile but now get 编辑:我得到它编译,但现在得到

WARNING: No mapping found for HTTP request with URI [/HelloWeb/] in DispatcherServlet with name 'HelloWeb 警告:在名称为'HelloWeb的DispatcherServlet中找不到带有URI [/ HelloWeb /]的HTTP请求的映射

Try with this; 试试这个;
Use Servlet API 2.5 and change your web.xml file as below: 使用Servlet API 2.5并如下更改您的web.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<servlet>
    <servlet-name>spring</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>

and spring-servlet.xml file to: spring-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:p="http://www.springframework.org/schema/p"
   xmlns:context="http://www.springframework.org/schema/context"
   xsi:schemaLocation="http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    http://www.springframework.org/schema/context
                    http://www.springframework.org/schema/context/spring-context-3.0.xsd ">

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

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"><!-- Here, the InternalResourceViewResolver class is used for the ViewResolver. -->
        <property name="prefix" value="/WEB-INF/jsp/"></property><!-- prefix can be any thing -->
        <property name="suffix" value=".jsp"></property>
    </bean>

EDIT: You have to include maven dependency for spring 3.x as below 编辑:您必须包括Spring 3.x的Maven依赖项,如下所示

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-context</artifactId>
  <version>3.1.0.RELEASE</version>
</dependency>
<dependency>
 <groupId>org.springframework</groupId>
 <artifactId>spring-webmvc</artifactId>
 <version>3.1.0.RELEASE</version>
</dependency>

As per your query in comments; 根据您在评论中的查询; Here in this case Spring is not creating default constructor so better move on to setter injection or create a default constructor. 在这种情况下,Spring不创建默认构造函数,因此最好继续进行setter注入或创建默认构造函数。

You can try to add these dependencies in your pom.xml file,Which dependency on what I hava forgotten. 您可以尝试将这些依赖项添加到您的pom.xml文件中,其中哪些依赖项我已经忘记了。

<dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.2.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.2.6.RELEASE</version>
        </dependency>

Hope fully this will the best Answer: 完全希望这将是最好的答案:

i was facing problem i download the eclipse Noen.3 and Dirctly Creating the Maven project. 我遇到了问题,我下载了Eclipse Noen.3并直接创建Maven项目。 Same Problem was occur that Server not start: DispatcherServlet class not Found Error: 发生服务器无法启动的相同问题:找不到DispatcherServlet类错误:

  1. i created the simple Dynamic Web Project and convert the project into Maven project 我创建了简单的Dynamic Web Project并将该项目转换为Maven项目

Steps: Right Click on the project configure->Convert to maven project 步骤:右键单击项目configure-> Convert to maven project

For Further Details i followed below the link http://javawebtutor.com/articles/spring/spring-mvc-hibernate-crud-example.php 有关更多详细信息,我点击了以下链接http://javawebtutor.com/articles/spring/spring-mvc-hibernate-crud-example.php

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.springframework.web.servlet.DispatcherServlet class 未找到 - org.springframework.web.servlet.DispatcherServlet class not found 错误[org.springframework.web.servlet.DispatcherServlet] - ERROR [org.springframework.web.servlet.DispatcherServlet] org.springframework.web.servlet.DispatcherServlet noHandlerFound - org.springframework.web.servlet.DispatcherServlet noHandlerFound CNF org.springframework.web.servlet.DispatcherServlet - CNF org.springframework.web.servlet.DispatcherServlet org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI in DispatcherServlet with name - org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI in DispatcherServlet with name 实例化servlet类org.springframework.web.servlet.DispatcherServlet时出错 - Error instantiating servlet class org.springframework.web.servlet.Dispatcherservlet org.springframework.web.servlet.DispatcherServlet noHandlerFound:Spring MVC - org.springframework.web.servlet.DispatcherServlet noHandlerFound : Spring MVC java.lang.classnotfoundexception org.springframework.web.servlet.dispatcherservlet - java.lang.classnotfoundexception org.springframework.web.servlet.dispatcherservlet 找到了org.springframework.web.servlet.DispatcherServlet,但是缺少另一个必需的类 - org.springframework.web.servlet.DispatcherServlet was found, but is missing another required class org.springframework.web.servlet.DispatcherServlet noHandlerFound用于基本的Spring示例 - org.springframework.web.servlet.DispatcherServlet noHandlerFound for basic spring example
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM