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



我的代码:我已经正确地配置了XML,添加了所有模式,但仍然会出错。

Config.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation=
       "http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/spring-context-3.2.xsd"
       xmlns:context="http://www.springframework.org/schema/context">
  <context:annotation-config />
  <context:component-scan base-package="com"/>
    <bean id="bean1" class="com.pojos.BookInfo">
    </bean>
</beans>

xmlns:context="http://www.springframework.org/schema/context"命名空间指定XSD的位置时出错:

更换

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

带有

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

总计:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation=
       "http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-3.2.xsd"
       xmlns:context="http://www.springframework.org/schema/context">
  <context:annotation-config />
  <context:component-scan base-package="com"/>
  <bean id="bean1" class="com.pojos.BookInfo">
  </bean>
</beans>

相关内容

最新更新