《Spring实战》-- 'cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element' 错误的解决办法

在Eclipse中新建了一个maven项目学习Spring,在 service.xml 中配置 Spring,想要学习‘面向切面的Spring’,service.xml 内容如下:

<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:aop="http://www.springframework.org/shema/aop"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:c="http://www.springframework.org/schema/c"
    xsi:schemaLocation="
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        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
        ">
   <bean id="audience" class="proxy.Audience" />
   <aop:config>
        <aop:aspect ref="audience">
            <aop:around
                pointcut="execution(** concert.Performance.perform(..))"
                method="watchPerformance(ProceedingJoinPoint)" />
        </aop:aspect>
   </aop:config>
</beans>

结果写 <aop: ** > 的时候,没有代码提示,而且总是出现错误提示:

Multiple annotations found at this line:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element
'aop:config'.

如图所示:

网上搜索解决方案,看到类似的问题是 xsi:schemaLocation 中的 url 没有配置好。思来想去,可能是因为自己在 <beans > 中的url没有写正确,就Ctrl+F 搜索‘http://www.springframework.org/schema/’,匹配的字符串就会背景高亮显示。发现果然是因为 “xmlns:aop="http://www.springframework.org/shema/aop" 没有写正确 --- shema 应该是 schema
改正以后就好了。ヾ(@^▽^@)ノ

猜你喜欢

转载自www.cnblogs.com/dongling/p/9461784.html