样本:

<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
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
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd"> <!--开启自动扫描-->
<context:component-scan base-package="com.huawei.test"/> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:config/jdbc.properties</value>
</list>
</property>
</bean>
<!--现在可以替换为如下方式-->
<!--使用逗号分隔多个值-->
<!--<context:property-placeholder location="classpath:config/jdbc.properties"/>--> <!--配置数据源-->
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
<property name="url" value="${datadb.url}"/>
<property name="username" value="${datadb.usernam}"/>
<property name="password" value="${datadb.password}"/>
<property name="driverClassName" value="${datadb.driverClassName}"/>
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<property name="mapperLocations" value="classpath:mybatis/*.xml"/>
</bean>
<bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.huawei.test.dao"/>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
</bean>
<!--数据库事务控制-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean> <!--使用annotation定义事务,比如使用注解-->
<tx:annotation-driven/>
<mvc:annotation-driven/>
</beans>

其中,xmlsn全称为xml namespace。使用xmlsn是为了解决命名冲突的问题。

使用xmlsn方式:

  使用语法: xmlns:namespace-prefix="namespaceURI"。其中namespace-prefix为自定义前缀,只要在这个XML文档中保证前缀不重复即可;namespaceURI是这个前缀对应的XML Namespace的定义。例如样板中国的context、mv、tx等,以及后面的xml namesapce定义路径。

xmlns:context="http://www.springframework.org/schema/context"

   这里定义了一个url为http://www.springframwork.org/schema/context的Namespace,并将其和前缀context绑定。这样,我们就可以在下面使用通过前缀来使用其定义的元素:

<context:component-scan base-package="com.huawei.test"/>

具体内容参考:https://my.oschina.net/itblog/blog/390001

建议再去看一下xml shema相关知识:http://www.w3school.com.cn/schema/index.asp

关于xml文件头部xmlsn的更多相关文章

  1. Spring 配置XML文件头部文件格式

    普通格式: <?xml version="1.0" encoding="UTF-8" ?> <beans xmlns:xsi="ht ...

  2. Silverlight TreeView 动态绑定Xml 文件

      随着应用程序的不断升级,客户的需求不断增多,程序员不得不对自己的应用程序做出相应的修改,如果修改的内容较多,那么就必须找出一种简便方法,下面就为大家介绍一下在SilverLight 中左边导航栏T ...

  3. Eclipse编辑XML文件的代码提示

    1.Eclipse无法解析的情形 Eclipse中编辑XML文件时,能够代码自动提示,是因为在XML头部引入了DTD文件(文档类型定义),Eclipse就是通过解析这个DTD文件,来达到代码提示的功能 ...

  4. Eclipse打开xml文件报校验错误解决办法

    XML文件在Eclipse中报校验错误: The content of element type "web-app" must match "(icon?,display ...

  5. XML文件解析DOM解析和SAX解析

    解析一个XML文档有哪些内容解析有:dom和sax两种dom:把整个XML文档放入内存,适合XML随机访问,占用内存资源大sax:事件驱动型的XML解析方式,顺序读取,不用一次装载整个文件,遇到标签会 ...

  6. Android Studio 学习 - AndroidManifest.xml文件学习

    首先,今天发现了一个很牛逼的教程网站:慕课网(http://www.imooc.com/).有很多大牛发布的教学视频.值得收藏.学习. 今天主要参照陈启超老大的视频,学习了多个Activity之间的切 ...

  7. Magento布局layout.xml文件详解

    解析顺序 布局xml文件一般位于app/design/{area}/{package}/{theme}/layout/目录下.Layout文件一般包含block.reference.action三种标 ...

  8. (python功能定制)复杂的xml文件对比,产生HTML展示区别

    功能的设计初衷: 处理复杂的xml对比,屏蔽同节点先后顺序的影响 主要涉及知识点: 1.xml解析 ------- ElementTree库 2.文件比对差别 ------- difflib库 3.获 ...

  9. Tomcat 的 server.xml 文件详解

    文件内容解读 <?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apac ...

随机推荐

  1. Spring全局变量

    压测spring框架的webservice接口,大并发量下响应值与预期值不一致 经查,开发在类中使用全局变量导致: springmvc核心控制器DispatcherServlet 默认为每个contr ...

  2. 初学Direct X(4)

    初学Direct X(4) 本文学着做出一个如下的小游戏 游戏方式是使用键盘控制红色的Bucket收集蓝色的炸弹 1.酝酿一下 现在我已经掌握: 将位图文件加载到内存 绘制位图到buckbuffer ...

  3. VMware SDK使用指南

    刚开始用VMware官方推荐的SDK,真的是又臭又长,代码结构不清晰,易读性差.后来VMware的同学给推荐了一款开源的SDK,一上手感觉工作效率提高了100倍!推荐大家使用~. 该SDK对VMwar ...

  4. 245. Subtree【LintCode java】

    Description You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds ...

  5. 腾讯地图和百度地图的PHP相互转换

    /** * 百度地图---->腾讯地图 * @param double $lat 纬度 * @param double $lng 经度 * @return array(); */ functio ...

  6. VT-x VT-d 虚拟化在win10中的问题

    win10真的是非常非常非常非常非常非常非常非常非常非常坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑坑!!!!!! 自带虚拟Buff不说,我不用竟然会有冲突!!!! 一度让我怀疑,我的CPU VT-x坏掉了!!! ...

  7. NMAP-主机扫描

    1.全面扫描 2.扫描指定段 3.ping扫描 只进行ping操作,十分隐蔽 4.无ping扫描 适用于防火墙禁止ping 5.TCP SYN扫描 6.TCP ACK扫描 7.UDP扫描 8.ICMP ...

  8. nodejs笔记--mysql篇(四)

    测试连接 var mysql = require('mysql'); //调用MySQL模块 //创建一个connection var connection = mysql.createConnect ...

  9. UML建模语言入门 -- 静态图详解 类图 对象图 包图 静态图建模实战

    发现个好东西思维导图, 最近开始用MindManager整理博客 . 作者 :万境绝尘  转载请注明出处 : http://blog.csdn.net/shulianghan/article/deta ...

  10. TCP系列09—连接管理—8、TCP Reset

    我们在介绍TCP头的时候,提到过其中有个RST标志位.当一个TCP报文中这个标志位打开的时候,我们叫做reset包(严格的说应该叫做reset段,但是很多时候段包帧并不加以区分)或者简单称呼为rese ...