cvc-complex-type.2.4.c:匹配的通配符是strict,但是没有为元素'context:component-scan'找到声明

时间:2016-10-23 19:15:19

标签: xml spring

我正在尝试将JPA与springframework集成,但是它给出了一个错误。 有人可以帮助解决这个问题。我真的不知道该修复什么。

<?xml version="1.0" encoding="UTF-8"?>
<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:tx="http://www.springframework.org/schema/tx"
    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.0.xsd
    http://www.springframework.org/schema/tx/ http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
    http://www.springframework.org/schema/context/ http://www.springframework.org/schema/context/spring-context-4.0.xsd" >

    <!-- It register the beans in context and scan the annotations inside beans and activate them -->
    <context:component-scan base-package="com.mycircle.dao"></context:component-scan>

    <!-- This allow for dispatching requests to Controllers -->
    <mvc:annotation-driven />

1 个答案:

答案 0 :(得分:0)

请注意,名称空间声明中使用的URI与schemaLocation中使用的URI(末尾的斜杠)不同:

xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="http://www.springframework.org/schema/context/ http://www.springframework.org/schema/context/spring-context-4.0.xsd"

两个URI必须相同。

希望它有所帮助。