属性“ xmlns :?”必须为元素类型“ beans”声明

时间:2018-08-26 04:39:37

标签: java xml spring

我正在尝试使用<context:component-scan base-package=""><context:annotation-config/>。我的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"
    xsi:schemaLocation="
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-4.3.xsd">
</beans>

但是必须为元素类型“ beans”声明eclipse抛出属性“ xmlns”和“ xmlns:aop”,“ xmlns:context”等。我怎样才能解决这个问题?预先感谢。

1 个答案:

答案 0 :(得分:0)

添加Spring bean xsd schemaLocation

<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" 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">