2014-02-03 2 views
4
<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> 

Я новый весной. У меня есть org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: строка 8 в документе XML из ресурса ServletContext [/WEB-INF/config/sdnext-servlet.xml] неверна; Вложенное исключение - org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 120; cvc-elt.1: Не удается найти декларацию элемента «beans». в файле конфигурации весны. Спасибо заранее.org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException весной

+0

У вас есть файл 'pom.xml'? Не могли бы вы опубликовать его, если так? –

+0

Нет, я не использую maven – user2823228

ответ

7

Я думаю, что ваше местоположение схемы недействительно. Поэтому, пожалуйста, измените 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> 
+0

, это помогло мне решить проблему с учебным пособием по множественному зрению, спасибо. – null

+0

Ваше приветствие ... :-) –

2

Похоже, что в конфигурации отсутствует закрывающий тег </beans>.

Также попробуйте указать версию схемы фасоли:

<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-3.2.xsd 
http://www.springframework.org/schema/tx http://www.springframework.org/schema/context-3.2.xsd 
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd"> 

</beans> 
0

Ваших бобов начинает тег плохо, замените; он работает для меня весной 3.0. Проверить схему:

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:wss="http://jax-ws.dev.java.net/spring/servlet" 
    xmlns:ws="http://jax-ws.dev.java.net/spring/core" xmlns:aop="http://www.springframework.org/schema/aop" 
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jee="http://www.springframework.org/schema/jee" 
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" 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/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd 
     http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd 
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd 
     http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd 
     http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 
Смежные вопросы