IDEA Spring项目编译时——通配符的匹配很全面, 但无法找到元素 'context:component-scan' 的声明。解决方法

版权声明:最终解释权归属Hern、HernSong(hernsong)、苍鹭、www.hernsong.com所有! https://blog.csdn.net/qq_36761831/article/details/88185943

原因

头文件没有写全

光有以下两个文件时不行的

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

xsi:schemaLocation="http://www.springframework.org/schema/context"

解决方法

应该再在xsi:schemaLocation里面补上

http://www.springframework.org/schema/context/spring-context.xsd

 全部头文件显示效果

<?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:context="http://www.springframework.org/schema/context"
       xmlns:aop="http://www.springframework.org/schema/aop"
       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
">

    <context:component-scan base-package="com.spring.aop"></context:component-scan>
</beans>

猜你喜欢

转载自blog.csdn.net/qq_36761831/article/details/88185943
今日推荐