Multiple annotations found at this line:解決

Multiple annotations found at this line:

       - schema_reference.4: Failedto read schema document'http://www.springframework.org/schema/context/spring-context-3.0.xsd', because1) could not find the document; 2) the document could not be read; 3) the rootelement

        of the document is not <xsd:schema>.

       - cvc-complex-type.2.4.c: Thematching wildcard is strict, but no declaration can be found for element'context:component-scan'.

啓動報這個的錯誤。

原因 : pom.xml文件中spring的版本與spring配置文件裏spring的版本配置不一致。

pom.xml中:

<properties>
		<springVersion>4.1.1.RELEASE</springVersion>
	</properties>


	<dependencies>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-web</artifactId>
			<version>${springVersion}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-webmvc</artifactId>
			<version>${springVersion}</version>
		</dependency>


spring配置文件中:

<?xml version="1.0" encoding="UTF-8"?>

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

改成同一版本之後啓動成功


原因:還有一種情況是xml文件中有中文的空格,或者開頭的地方多了空格。也會出現這種錯誤。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章