在使用注解装配的时候,遇到了如下报错:
通配符的匹配很全面, 但无法找到元素 ‘context:annotation-config’ 的声明
bean的配置文件如下:
<?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:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
<--当时直接copy的这个地方-->
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/beans/spring-context.xsd
<--正确--> 不同之处
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
不同之处
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/beans/spring-aop.xsd
">
<context:annotation-config/>
<bean id="dog" class="pojo.Dog"/>
<bean id="cat" class="pojo.Cat"/>
<bean id="people" class="pojo.People"/>
</beans>