<beans xmlns="http://www.springframework.org/schema/beans"
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.xsd">
</beans>
我们在配置spring xml 的bean 的时候,会看到xmlns xmlns:xsi xsi:schemaLocation 这几个配置,一般都是直接拷贝,并不知晓具体含义,故此处对含义做下解析,弥补下空白的基础知识。
xmlns
xmlns 的全称为 xml namespace,即 xml 命名空间,这个很好理解,和 java 中 package 和 c# 中 namespace 的概念基本一致,起的作用也基本一致:区分重复元素
xmlns 格式定义如下:
xmlns[:name] = "uri"
我们可以自己定义结构,避免冲突,然后需要指定下xmlns 对应的xsi:schemaLocation
xsi:schemaLocation 其实就是
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd"
参考文档: