1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-config.dtd">
  4. <!-- 注意:每个标签必须按顺序写,不然蛋疼的DTD会提示错误:The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,plugins?,environments?,mappers?)". -->
  5. <configuration>
  6. <!-- 属性配置 -->
  7. <properties resource="com/mybatisdemo/config/mysql-jdbc-connection.properties">
  8. <!-- 相同属性:最高优先级的属性是那些作为方法参数的,然后是资源/url 属性,最后是 properties元素中指定的属性 -->
  9. <property name="username" value="root"/>
  10. <property name="password" value="sa"/>
  11. </properties>
  12. <!-- 设置缓存和延迟加载等等重要的运行时的行为方式 -->
  13. <settings>
  14. <!-- 设置超时时间,它决定驱动等待一个数据库响应的时间  -->
  15. <setting name="defaultStatementTimeout" value="25000"/>
  16. </settings>
  17. <!-- 别名 -->
  18. <typeAliases>
  19. <typeAlias alias="UserInfo" type="com.mybatisdemo.entity.UserInfo"/>
  20. </typeAliases>
  21. <environments default="development">
  22. <!-- environment 元素体中包含对事务管理和连接池的环境配置 -->
  23. <environment id="development">
  24. <transactionManager type="JDBC" />
  25. <!-- type分三种:
  26. UNPOOLED是每次被请求时简单打开和关闭连接
  27. UNPOOLED的数据源仅仅用来配置以下 4 种属性driver,url,username,password
  28. POOLED :JDBC连接对象的数据源连接池的实现,不直接支持第三方数据库连接池
  29. -->
  30. <dataSource type="POOLED">
  31. <property name="driver" value="${driver}" />
  32. <property name="url" value="${url}" />
  33. <property name="username" value="${username}" />
  34. <property name="password" value="${password}" />
  35. </dataSource>
  36. </environment>
  37. </environments>
  38. <!-- ORM映射文件 -->
  39. <mappers>
  40. <mapper resource="com/mybatisdemo/entity/config/UserInfoSqlMap.xml" />
  41. </mappers>
  42. </configuration>

注意:

①xml中的标签顺序不能随便调换,否则会提示错误

②MyBatis使用自带的数据库连接池,不直接支持第三方连接池,不过网上有创建第三方连接池的方法

③以前别名(<typeAliases>)可以在sqlMap标签中创建,但现在需要在configuration标签中创建

④该配置文件可随意取名,在读取配置文件时指定该XML文件路径即可:

  1. //读取核心配置文件
  2. Reader reader = Resources.getResourceAsReader("com/mybatisdemo/config/Configuration.xml");
  3. //创建SessionFactory实例
  4. SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);

The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?...的更多相关文章

  1. The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,reflectorFactory?,plugins?,environments?,databaseIdProv

    在mybatis配置文件config.xml中报错: The content of element type "configuration" must match "(p ...

  2. 【转】The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?...

    [转]The content of element type "configuration" must match "(properties?,settings?,typ ...

  3. mybatis配置文件,注意标签配置顺序。否则报错The content of element type "configuration" must match "(properties?,settings?,...怎么解决

    感谢原作者http://www.cnblogs.com/zhoumingming/p/5417014.html 注意每个标签必须按照顺序写,不然就会提示错误 顺序是 <?xml version= ...

  4. 元素类型为 "configuration" 的内容必须匹配 "(properties?,settings?,typeAliases?,typeHandlers?

    报错主要部分如下: Error building SqlSession.### Cause: org.apache.ibatis.builder.BuilderException: Error cre ...

  5. Multiple annotations found at this line: - The content of element type "mapper" must match "EMPTY". - Attribute "namespace" must be declared for element type "mapper".

    今天在mybatis的mapper映射配置文件中遇到了这样的问题,困扰了我3个小时: Multiple annotations found at this line: - The content of ...

  6. The content of element type "package" must match "(result-types?,interceptors?...

    错误:“The content of element type "package" must match "(result-types?,interceptors?,de ...

  7. web.xml配置bug之提示The content of element type "web-app" must match "(icon?,display- name?,description?,distributable?,

    错误:配置web.xml时,出现红色叉叉,提示 The content of element type "web-app" must match "(icon?,disp ...

  8. The content of element type "beans" must match "(description?,(import|alias|bean)*)

    The content of element type "beans" must match "(description?,(import|alias|bean)*) - ...

  9. The content of element type "package" must match "(result-types?,interceptors?,default-interceptor-ref?,default-action-ref?,default-class-ref?,global- results?,global-exception-mappings?,action*)".

    报错 The content of element type "package" must match "(result-types?,interceptors?,def ...

随机推荐

  1. NEFU 2016省赛演练一 F题 (高精度加法)

    Function1 Problem:F Time Limit:1000ms Memory Limit:65535K Description You know that huicpc0838 has b ...

  2. ip

    D组播地址 主机号 用于识别该网络中的主机. IP地址分为五类,A类保留给政府机构,B类分配给中等规模的公司,C类分配给任何需要的人,D类用于组播,E类用于实验,各类可容纳的地址数目不同. A.B.C ...

  3. int *p()与int (*p)()的区别

    int *p()是返回指针的函数 int (*p)()是指向函数的指针   返回指针的函数: int *a(int x,int y); 有若干个学生的成绩(每个学生有4门课程),要求在用户输入学生序号 ...

  4. 安装win7或win8系统时UEFI和Legacy模式的设置

    很多新型号的笔记本或台式机主板都开始支持UEFI模式,比起原来的Legacy启动减少了BIOS自检,加快平台启动,如下图所示Legacy,UEFI启动过程: 安装系统,建议选择Legacy模式,在UE ...

  5. PIGOSS

    http://blog.sina.com.cn/s/blog_865bc4c60102wkb1.html

  6. WPF控件委托

    this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (ThreadStart)delegate { //要执行的代码 });

  7. cocos2dx游戏开发——微信打飞机学习笔记(四)——GameScene的搭建

    一.创建文件 首先呢,就是那个创建新的.h 和 .cpp 的文件,然后可以起名为GameScene 最重要的就是一定要创建在Classes的目录下哦= =,别手抖= =. 二.GameScene.h和 ...

  8. matlab参数查询

    nargout nargout的作用是在matlab中定义一个函数时, 在函数体内部, nargout指出了输出参数的个数(nargin指出了输入参数的个数). 特别是在利用了可变参数列表的函数中, ...

  9. 解决 Agent admitted failure to sign using the key 问题 with ssh

    之前如果建立 ssh 连接,只要將公鑰複製到 ~/.ssh/authorized_keys 就可以利用金鑰登入而不需要建立密碼. 現在的 ssh 使用同樣的方法會出現錯誤訊息 Agent admitt ...

  10. js:语言精髓笔记4----面向对象概要与运算符二义性

    实例创建:obj = new contructor[(arguments)]; //如果没有参数可以忽略括号:所以注意这不是函数调用: 直接量与初始器:在之前的基本表达式中将直接量与初始器分开,这时因 ...