样本:

<?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. git服务器搭建及eclipse使用git

    一.搭建git服务器 1.yum install git 2.新建用户linux用户git,管理git服务 useradd git passwd git 3.初始化git仓库 git init --b ...

  2. JAVA基础学习之路(八)[1]String类的基本特点

    String类的两种定义方式: 直接赋值 通过构造方法赋值 //直接赋值 public class test2 { public static void main(String args[]) { S ...

  3. 几个常见移动平台浏览器的User-Agent

    之前介绍的手机站跳转url的一片文稿中提到,依据User Agent判断终端的方法.(文章地址:http://www.cnblogs.com/dereksunok/p/3664169.html ) 若 ...

  4. windows store无法登陆的问题解决方案

    Windows应用商店或商店Apps无法打开或闪退的可选方法 (仅用于10565之前的Windows 10版本) 右键点击任务栏,选择"属性",切换到"导航"选 ...

  5. 一道java笔试题

    输入一串用空格隔开的数字串,对于数字串的奇数位按升序排序,偶数位按降序排序. 示例输入: 4 6 2 3 6 7 8 1 处理过程: 奇数位:4 2 6 8 升序排序结果: 2 4 6 8 偶数位:6 ...

  6. wpa_supplicant之eloop_run分析

    部分内容转自http://blog.chinaunix.net/uid-20273473-id-3128151.html 重要结构体!!! struct eloop_sock { int sock; ...

  7. Python如何运行

    Python是一种解释型语言,在执行Python的时,解释器将源代码source code翻译成字节码byte code,然后byte code交给Python虚拟机PVM去执行,整个流程如下图所示: ...

  8. 欢迎来怼——第14次Scrum会议(10/26)

    一.小组信息 队名:欢迎来怼小组成员队长:田继平成员:李圆圆,葛美义,王伟东,姜珊,邵朔,冉华 小组照片 二.开会信息 时间:2017/10/26  17:00~17:13(总计13min).地点:计 ...

  9. Pipeline组项目Postmortem

    Pipeline组项目Postmortem 1.     设想和目标 1)目标我们的软件要解决什么问题?是否定义得很清楚?是否对典型用户和典型场景有清晰的描述? 我们的项目是学霸系统PipeLine, ...

  10. win7 个人电脑 IIS7服务器(web服务器) 同一局域网下均可访问本机网页

    建立web服务器: 1.控制面板-->程序-->打开或关闭windows功能-->internet信息服务全部打钩,确定即可. 访问网页: 1.C:\inetpub\wwwroot\ ...