当前位置: 首页 > 面试题库 >

匹配的通配符是严格的,但是找不到元素'context:component-scan的声明

许马鲁
2023-03-14
问题内容

尝试我的第一个春季项目时遇到以下错误:

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'context:component-scan

这是applicationContext.xml

<?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:p="http://www.springframework.org/schema/p"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
       http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

        <context:component-scan base-package="com.xyz" />

</beans>

是什么导致错误?


问题答案:

您尚未指定上下文名称空间的架构位置,这是此特定错误的原因:

<beans .....
  xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context.xsd">


 类似资料:
  • 问题内容: 我正在尝试配置JSF + Spring + hibernate,并且想运行一个测试,但是当我在application-context.xml文件中使用此“ tx:annotation-driven”时,出现此错误: 匹配的通配符是严格的,但是找不到元素’tx:annotation-driven’的声明 这是我的application-context.xml: 这是我的CourseSer

  • 问题内容: 我正在尝试配置NTLM身份验证,但收到错误: cvc-complex-type.2.4.c:匹配的通配符是严格的,但是找不到元素’http’的声明。 我阅读了很多类似错误的主题,但是找不到解决我问题的方法。 我的导致错误的security.xml文件是: 因为从3.X版本开始,Spring Security不再包含NTLM扩展,所以我从http://aloiscochard.blogs

  • 问题内容: 所以我遇到了类似这里的问题… Spring3.0错误:匹配的通配符很严格,但是找不到元素的声明、 我的pom看起来像这样 但是,当我尝试在Websphere上运行该服务时,得到以下信息… 看来这与我的链接有所不同,因为我已经在名称空间中有了模式。有任何想法吗? 问题答案: 请注意-中的其他项的模式-来自属性的每个名称空间URI 后面都应带有其各自的XSD位置:

  • 问题内容: 我已经在我的lib文件夹中添加了spring-security-config-3.1.0.RC3.jar,但仍然出现此错误。可能是什么原因? 这是我的dispatcher-servlet.xml 问题答案: 你有这个: 但您在这里没有提及它: 要解决这个问题,您应该 那里,就像 注意:模式引用实际上没有提到Spring版本,以便于升级,这是很常见的做法,因此您应该使用like之类的引用

  • 我知道很多人都问过这个问题。我正在张贴,因为我尝试了所有的选项,但仍然得到错误。 我正在使用Spring4.01释放罐

  • 问题内容: 有没有一种方法可以使用querySelector或进行通配符元素名称匹配querySelectorAll?我看到属性查询中支持通配符,但不支持元素本身。 我要解析的XML文档基本上是一个简单的属性列表,我需要查找名称中包含某些字符串的元素。 我意识到,如果我需要的话,XML文档可能需要进行重组,但这不会发生。 除了返回使用显然不推荐使用的XPath(IE9删除了它)之外,任何解决方案都