无法找到元素'beans'的声明

时间:2018-06-19 07:14:22

标签: javabeans

  

下面是我的spring-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/mvc"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:lang="http://www.springframework.org/schema/lang"
     xmlns:p="http://www.springframework.org/schema/p"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
     xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"

    xsi:schemaLocation="http://www.springframework.org/schema/lang
    http://www.springframework.org/schema/lang/spring-lang.xsd

    http://www.springframework.org/schema/jee
    http://www.springframework.org/schema/jee/spring-jee.xsd

    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd

    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc.xsd 

    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd

      http://www.springframework.org/schema/util
    http://www.springframework.org/schema/util/spring-util.xsd

    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 

    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd ">

    <!-- adding support for component scanning -->
    <context:component-scan base-package="com.work" />
    <context:property-placeholder location="classpath:jdbc.properties" />

    <!-- adding support for convertion ,formatting and validating support -->
    <mvc:annotation-driven />


    <!-- define a spring mvc view resolver -->
    <bean id="jspViewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsps/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <!-- step1: define datasource/connection pool -->
    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="${jdbc.driverName}" />
        <property name="url" value="${jdbc.databaseurl}" />
        <property name="username" value="${jdbc.username}" />
        <property name="password" value="${jdbc.password}" />

    </bean>

    <!-- step2:setup hibernate session factory -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <!-- The packages that contain our Hibernate model classes -->
        <property name="packagesToScan">
            <list>
                <value>com.work.entity</value>
            </list>
        </property>

        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">${jdbc.dialect}</prop>

            </props>
        </property>


    </bean>

    <!-- Hibernate transaction management -->
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>

    <!-- enable configuration for trasactional behaviour based on annatations -->
    <tx:annotation-driven transaction-manager="transactionManager" />






</beans>
  

我得到和例外如下

     

描述资源路径位置类型cvc-elt.1:找不到   元素'豆'的声明。 spring-servlet.xml / Spring Hibernate   演示/ WebContent / WEB-INF第37行XML问题

     

我在lib文件夹中添加了hibernate和spring的jar,   请更正错误?

0 个答案:

没有答案