首页 > 解决方案 > 属性“xmlns:?” 必须为元素类型“beans”声明

问题描述

我正在尝试使用<context:component-scan base-package="">and <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>

但是eclipse一直抛出属性“xmlns”,并且必须为元素类型“beans”声明“xmlns:aop”、“xmlns:context”等。我怎样才能解决这个问题?提前致谢。

标签: javaxmlspring

解决方案


添加spring beans 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">


推荐阅读