Schema_reference.4: Не удалось прочитать документ схемы "http://www.springframework.org/schema/beans/spring- beans -4.1.5.xsd
Я получаю сообщение об ошибке в spring -dispatcher.xml в eclipse, как показано ниже.
schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/beans/spring-
beans-4.1.5.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root
element of the document is not <xsd:schema>.
У меня есть последние библиотеки spring...
spring-beans-4.1.5.RELEASE.jar
spring-beans-4.1.5.RELEASE-javadoc.jar
spring-beans-4.1.5.RELEASE-sources.jar
spring-context-4.1.5.RELEASE.jar
spring-context-4.1.5.RELEASE-javadoc.jar
spring-context-4.1.5.RELEASE-sources.jar
spring-context-support-4.1.5.RELEASE.jar
spring-context-support-4.1.5.RELEASE-javadoc.jar
spring-context-support-4.1.5.RELEASE-sources.jar
spring-webmvc-4.1.5.RELEASE.jar
spring-webmvc-4.1.5.RELEASE-javadoc.jar
spring-webmvc-4.1.5.RELEASE-sources.jar
spring-webmvc-portlet-4.1.5.RELEASE.jar
spring-webmvc-portlet-4.1.5.RELEASE-javadoc.jar
spring-webmvc-portlet-4.1.5.RELEASE-sources.jar
spring -dispatcher.xml, как указано ниже...
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
Было бы здорово, если бы мне помогли... Посты с одним и тем же предметом не помогли мне решить эту проблему. Спасибо заранее...
Ответы
Ответ 1
Ошибка связана с тем, что не удалось найти xsd. Попробуйте сделать ниже, что использует определенную версию 4.1.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
Или, если вы не укажете версию, она попытается использовать последнюю версию.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
Ответ 2
В любом контейнере Spring нет такого xsd:
http://www.springframework.org/schema/beans/spring-beans-4.1.5.xsd
Spring xsd для Spring 4.1.x можно ссылаться на:
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
или лучше:
http://www.springframework.org/schema/beans/spring-beans.xsd
Соответствие между URL-адресом и реальным местоположением внутри каждого баннера Spring можно найти в файле META-INF/spring.schemas, поэтому URL-адрес "версия меньше" будет работать, когда u upgrade Spring.
Ответ 3
В моем случае он ушел, добавив
<?xml version="1.0" encoding="utf-8"?>
до spring -dispatcher.xml, а затем запустить проект обновления maven.
Ответ 4
Поверьте мне или нет, это может быть проблемой maven, если вы используете ее, и все закончилось таким образом из ничего. Я знаю, что это может быть не ваше дело, но если да, обновите свой проект maven. Если вы используете Eclipse IDE:
- Щелкните правой кнопкой мыши имя проекта.
- Maven.
- Обновить проект...
Опять же, этот может быть вашим. Для меня это работало. Это может работать и с кем-либо, кто находится в той же ситуации.
Ответ 5
От Cosmina I. - Профессиональный сертифицированный профессионал Spring Экзамен разработчика Учебное пособие - 2017
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
Рекомендуемая (лучшая) практика - это использовать, так как версия быть правильно идентифицированным из версии зависимости Spring в проект. Кроме того, другим преимуществом является то, что вы можете обновить Springверсию, которую вы используете, и новые спецификации определения будут автоматически поддерживается в ваших конфигурационных файлах без вашего изменять их
Ответ 6
Попробуй, это сработало для меня
<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"
xsi:schemaLocation = "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
Ответ 7
Я зачислил курс spring на удемию. Я следовал за каждым шагом, который показал мне мой инструктор.
Поэтому, если вы используете spring mvc и hibernate, вы можете столкнуться с этой ошибкой
Не удалось прочитать документ схемы http://www.springframework.org/schema/tx/spring-tx.xsd 'и т.д. Для:
<mvc:annotation-driven/> and <tx:annotation-driven transaction-manager="myTransactionManager" /> elements
в моем конфигурационном файле spring у меня были эти два URL
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
в xsi: schemaLocation, которую я заменил на
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
На самом деле посетите эти два сайта
http://www.springframework.org/schema/mvc/ и http://www.springframework.org/schema/tx/
и только что добавили последнюю версию spring -mvc и spring -tx i.e, spring -mvc-4.2.xsd и spring -tx-4.2.xsd, как показано выше.
По моему мнению, спецификация версии явно не является хорошей практикой.
Это сработало для меня, надеюсь, это сработает и для вас.
Спасибо.