2012-05-15 3 views
1

Я пытаюсь использовать:диспетчеру-сервлет: Invalid контент был обнаружен, начиная с элемента «хранилищами»

<repositories base-package="com.site.cmt.repositories" repository-impl-postfix=""> 
    <repository id="variableRepository" /> 
</repositories> 

, но я получаю эту ошибку:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 71 in XML document from ServletContext resource [/WEB-INF/dispatcher-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 71; columnNumber: 94; cvc-complex-type.2.4.a: Invalid content was found starting with element 'repositories'. One of '{"http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"], "http://www.springframework.org/schema/beans":beans}' is expected.

Я думал, что загрузка все правильно ...

<beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xmlns:p="http://www.springframework.org/schema/p" 
     xmlns:context="http://www.springframework.org/schema/context" 
     xmlns:mvc="http://www.springframework.org/schema/mvc" 
     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:jpa="http://www.springframework.org/schema/data/jpa" 
     xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.1.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-3.1.xsd 
     http://www.springframework.org/schema/tx 
     http://www.springframework.org/schema/tx/spring-tx-3.1.xsd 
     http://www.springframework.org/schema/jee 
     http://www.springframework.org/schema/jee/spring-jee-3.1.xsd 
     http://www.springframework.org/schema/data/jpa 
     http://www.springframework.org/schema/data/jpa/spring-jpa-1.1.xsd"> 

ответ

6

Пространство имен для тега репозиториев неправильно, просто изменить его на:

<repository:repositories base-package="com.site.cmt.repositories" repository-impl-postfix=""> 
    <repository:repository id="variableRepository" /> 
</repository:repositories> 

или установить пространство имен по умолчанию XML в хранилище:

xmlns="http://www.springframework.org/schema/data/repository" 

Обновление: Я извиняюсь, я получил пространство имен неправильно, в вашем случае, на самом деле вы использовали jpa в качестве префикса для правильное хранилище, связанных с пространством имен, которое является http://www.springframework.org/schema/data/jpa, так что вы в основном должны использовать:

<jpa:repositories base-package="com.site.cmt.repositories" repository-impl-postfix=""> 
    <jpa:repository id="variableRepository" /> 
</jpa:repositories> 

Но это могло бы быть лучше просто переназначить пр репозитария efix в поле имен http://www.springframework.org/schema/data/jpa, то есть нормальное convention

+0

Это похоже на работу ... вид ... 'Соответствующий шаблон является строгим, но не существует декларации для репозитория элемента: репозитории'' – Webnet

+0

Shouldn 't Мне просто нужно уметь помещать '@ Repository'? – Webnet

+0

Да @Webnet, я обновил ответ, у меня было неправильное пространство имен. Вам все равно нужно указать, какие пакеты сканировать для компонентов репозитория, хотя –

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