2015-03-05 5 views
1

Ниже представлено мое объявление sdnext-servlet.xml. Я получаю эту ошибкуНевозможно найти объявление элемента «beans».

«Не удается найти декларацию элемент" фасоль»

даже если я нахожусь в Интернете. Я использую Spring 3.0.1.

Вот sdnext-servlet.xml:

<beans xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://www.springframework.org/schema/beans" 
    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 
http://www.springframework.org/schema/tx 
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> 

    <context:property-placeholder location="classpath:resources/database.properties"> 
    </context:property-placeholder> 
    <context:component-scan base-package="com"> 
    </context:component-scan> 

    <tx:annotation-driven transaction-manager="hibernateTransactionManager"> 
    </tx:annotation-driven> 

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

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

    <bean 
     class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" 
     id="sessionFactory"> 
     <property name="dataSource" ref="dataSource"></property> 
     <property name="annotatedClasses"> 
      <list> 
       <value>com.dto.Causer</value> 
      </list> 
     </property> 
     <property name="hibernateProperties"> 
      <props> 
       <prop key="hibernate.dialect">${hibernate.dialect}</prop> 
       <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> 
       <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto} </prop> 
      </props> 
     </property> 
    </bean> 

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

Попытка удалить версию жгутов SchemaLocation как этот 'HTTP: // www.springframework.org/схема/бобы/весна-beans.xsd'. Какую версию весны вы используете? – Xstian

+0

am using spring 3.0.1 – KS6

+0

Я удалил версию и попытался, все еще получая ту же ошибку. – KS6

ответ

0

Это schemaLocation, не schemalocation.

После исправления этой ошибки закрытие context:property-placeholder и несколько других подобных элементов, а не разрешение их содержания содержат символы новой строки.

Вот ваш обновленный, действительный XML:

<beans xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:tx="http://www.springframework.org/schema/tx" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns="http://www.springframework.org/schema/beans" 
     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 
          http://www.springframework.org/schema/tx 
          http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> 

    <context:property-placeholder location="classpath:resources/database.properties"/> 
    <context:component-scan base-package="com"/> 

    <tx:annotation-driven transaction-manager="hibernateTransactionManager"/> 

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

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

    <bean 
     class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean" 
     id="sessionFactory"> 
    <property name="dataSource" ref="dataSource"></property> 
    <property name="annotatedClasses"> 
     <list> 
     <value>com.dto.Causer</value> 
     </list> 
    </property> 
    <property name="hibernateProperties"> 
     <props> 
     <prop key="hibernate.dialect">${hibernate.dialect}</prop> 
     <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> 
     <prop key="hibernate.hbm2ddl.auto">${hibernate.hbm2ddl.auto} </prop> 
     </props> 
    </property> 
    </bean> 

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

Спасибо, сработало. – KS6

Смежные вопросы