java - spring 中的 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException

标签 java xml spring spring-mvc

<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"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemalocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">


<context:property-placeholder location="classpath:/database.properties" />


<context:component-scan base-package="com.dineshonjava" />
<tx:annotation-driven transaction-manager="hibernateTransactionManager" />


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

<bean id="dataSource"
    class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="${jdbc.driverClassName}" />
    <property name="url" value="${jdbc.url}" />
    <property name="username" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
</bean>

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">

    <property name="dataSource">
        <ref bean="dataSource" />
    </property>

    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>

    <property name="annotatedClasses">
        <list>
            <value>com.dineshonjava.model.Employee</value>
        </list>
    </property>
</bean>

<bean class="org.springframework.orm.hibernate3.HibernateTransactionManager"
    id="hibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory"></property>
</bean>
</beans>  

我是 Spring 的新人。我有 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:来自 ServletContext 资源 [/WEB-INF/config/sdnext-servlet.xml] 的 XML 文档中的第 8 行无效;嵌套异常是 org.xml.sax.SAXParseException;行号:8;列数:120; cvc-elt.1: 找不到元素“beans”的声明。在 spring 配置文件中。提前致谢。

最佳答案

我认为您的架构位置无效。所以请在 spring 配置文件中将 xsi:schemalocation 更改为 xsi:schemaLocation。

<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"
xmlns:mvc="http://www.springframework.org/schema/mvc"     xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">

..........

</beans>

关于java - spring 中的 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21525135/

相关文章:

java - SAAJ:TextNode 中的 XML。报价未转义

xml - 您可以转换无序的 xml 以匹配 xsd :sequence order?

java - android从类似于用于字符串的方法的微调器中获取一个整数

java - 为什么 Spring RequestMapping 没有 @Controller 就无法工作?

java - 这个 HQL 查询有什么问题?

java - GridBagLayout - 我的列数似乎比指定的少,但为什么?

java - 无法将 java.lang.String 类型的属性值转换为所需类型实体

spring - 无法自动接线。有多个 'DataSource' 类型的 bean

java - 没有 Maven 的 Elasticsearch

Java比较long值的正确方法