The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHand
来源:互联网 发布:大数据技术案例应用 编辑:程序博客网 时间:2024/05/18 06:21
The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?...
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-config.dtd">
- <!-- 注意:每个标签必须按顺序写,不然蛋疼的DTD会提示错误:The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,plugins?,environments?,mappers?)". -->
- <configuration>
- <!-- 属性配置 -->
- <properties resource="com/mybatisdemo/config/mysql-jdbc-connection.properties">
- <!-- 相同属性:最高优先级的属性是那些作为方法参数的,然后是资源/url 属性,最后是 properties元素中指定的属性 -->
- <property name="username" value="root"/>
- <property name="password" value="sa"/>
- </properties>
- <!-- 设置缓存和延迟加载等等重要的运行时的行为方式 -->
- <settings>
- <!-- 设置超时时间,它决定驱动等待一个数据库响应的时间 -->
- <setting name="defaultStatementTimeout" value="25000"/>
- </settings>
- <!-- 别名 -->
- <typeAliases>
- <typeAlias alias="UserInfo" type="com.mybatisdemo.entity.UserInfo"/>
- </typeAliases>
- <environments default="development">
- <!-- environment 元素体中包含对事务管理和连接池的环境配置 -->
- <environment id="development">
- <transactionManager type="JDBC" />
- <!-- type分三种:
- UNPOOLED是每次被请求时简单打开和关闭连接
- UNPOOLED的数据源仅仅用来配置以下 4 种属性driver,url,username,password
- POOLED :JDBC连接对象的数据源连接池的实现,不直接支持第三方数据库连接池
- -->
- <dataSource type="POOLED">
- <property name="driver" value="${driver}" />
- <property name="url" value="${url}" />
- <property name="username" value="${username}" />
- <property name="password" value="${password}" />
- </dataSource>
- </environment>
- </environments>
- <!-- ORM映射文件 -->
- <mappers>
- <mapper resource="com/mybatisdemo/entity/config/UserInfoSqlMap.xml" />
- </mappers>
- </configuration>
注意:
①xml中的标签顺序不能随便调换,否则会提示错误
②MyBatis使用自带的数据库连接池,不直接支持第三方连接池,不过网上有创建第三方连接池的方法
③以前别名(<typeAliases>)可以在sqlMap标签中创建,但现在需要在configuration标签中创建
④该配置文件可随意取名,在读取配置文件时指定该XML文件路径即可:
- //读取核心配置文件
- Reader reader = Resources.getResourceAsReader("com/mybatisdemo/config/Configuration.xml");
- //创建SessionFactory实例
- SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
阅读全文
0 0
- The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHand
- The content of element type "sqlMapConfig" is incomplete, it must match "(properties?,settings?,resu
- mybatis配置文件,注意标签配置顺序。否则报错The content of element type "configuration" must match "(properties?,settin
- The content of element type "configuration" must match "EMPTY". Children of type "comment" are not a
- log4j.xml警告log4j:WARN The content of element type "log4j:configuration" must match "(renderer*,appen
- The content of element type "hibernate-configuration" must match "(session-factory,security?)
- org.xml.sax.SAXParseException: The content of element type "configuration" must match
- log4j.xml警告log4j:WARN The content of element type "log4j:configuration" must match "(renderer*,appen
- log4j.xml警告log4j:WARN The content of element type "log4j:configuration" must match "(renderer*,appen
- mybatis-config.xml:报SAXParseException: The content of element type "configuration" must match
- org.xml.sax.SAXParseException: The content of element type “sqlMapConfig” must match “(properties?,s
- org.xml.sax.SAXParseException: The content of element type “sqlMapConfig” must match “(properties?,s
- ibatis:The content of element type "sqlMap" must match
- The content of element type "package" must match...
- The content of element type "struts-config" must match 解决方案
- The content of element type "package" must match 。。。。。。
- The content of element type "package" must match 随笔
- The content of element type "web-app" must match "
- [机器学习入门] 李宏毅机器学习课程回顾 + 接下来的学习声明
- war反编译成java项目
- 设置虚拟机既能连ssh,也能上网
- Laravel学习过程之基础知识学习和使用(二)
- 2017-8-21破损的键盘 UVa 11988
- The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHand
- Merge, join, and concatenate合并,加入和连接
- SpringMVC启动过程详解(li)
- python3安装 使用 pdfminer3k python在线、本地读取PDF文件
- 阿里云Windows2008外网无法访问开启80端口实现外网访问网站
- SFDC之trigger那些事儿
- 将jar生成为maven需要的jar格式
- 【C#学习】Reflection 反射
- 2017中国大学生程序设计竞赛(网络选拔赛) HDU 6154 CaoHaha's staff