Dispatcher-Servlet.xml找不到具有名称的bean的类[org.springframework.web.servlet.mvc.support]

时间:2018-02-21 20:25:09

标签: java spring fullcalendar

我一直在尝试实现FullCalendar插件,当我通过Apache Tomcat运行程序时出现此错误:

Cannot find class [org.springframework.web.servlet.mvc.support] for bean with name 
'org.springframework.web.servlet.mvc.support#0' defined in ServletContext resource 
[/WEB-INF/dispatcher-servlet.xml]; nested exception is java.lang.ClassNotFoundException: 
org.springframework.web.servlet.mvc.support

Dispatcher-Servlet.xml 类是错误源自

的地方
<?xml version="1.0" encoding ="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">

    <bean class = "org.springframework.web.servlet.mvc.support"/>

    <context:component-scan base-package="demo.*;"/>

    <mvc:annotation-driven/>

    <context:annotation-config/>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/db1"/>
        <property name="username" value="root"/>
        <property name="password" value="root"/>
    </bean>

    <bean id ="sessionFactory" class = "org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/> 
        <property name = "configLocation">
            <value>classpath:hibernate.cfg.xml</value>
        </property>
        <property name = "hibernateProperties">
            <props>
                <prop key = "hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
            </props>
        </property>
    </bean>

    <tx:annotation-driven />

    <bean id = "transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name = "dataSource" ref ="dataSource"/>
        <property name = "sessionFactory" ref = "sessionFactory"/>
    </bean>

    <bean id ="viewResolver"
        class = "org.springframework.web.servlet.view.internalresourceviewresolver"
        p:prefix = "/WEB-INF/jsp/"
        p:suffix = ".jsp"/>  
    </beans>

我认为我在这里遗漏了一些代码,但我不确定遗漏了什么以及错误显示的原因。

1 个答案:

答案 0 :(得分:0)

异常说它无法找到Web Servlet Jar下的类org.springframework.web.servlet.mvc.support

<dependency>
     <groupId>org.springframework</groupId>
     <artifactId>org.springframework.web.servlet</artifactId>
     <version>x.x.x</version>
</dependency>

你能检查一下你是否需要一个?