【转】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);
【转】The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?...的更多相关文章
- 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 ...
- The content of element type "configuration" must match "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?...
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC & ...
- mybatis配置文件,注意标签配置顺序。否则报错The content of element type "configuration" must match "(properties?,settings?,...怎么解决
感谢原作者http://www.cnblogs.com/zhoumingming/p/5417014.html 注意每个标签必须按照顺序写,不然就会提示错误 顺序是 <?xml version= ...
- 元素类型为 "configuration" 的内容必须匹配 "(properties?,settings?,typeAliases?,typeHandlers?
报错主要部分如下: Error building SqlSession.### Cause: org.apache.ibatis.builder.BuilderException: Error cre ...
- 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 ...
- The content of element type "package" must match "(result-types?,interceptors?...
错误:“The content of element type "package" must match "(result-types?,interceptors?,de ...
- 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 ...
- The content of element type "beans" must match "(description?,(import|alias|bean)*)
The content of element type "beans" must match "(description?,(import|alias|bean)*) - ...
- 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 ...
随机推荐
- centos7 rabbitmq系统部署
CentOS7 1.安装系统 基础设施服务器:Java平台.Linux远程管理.开发工具 2.打开网络连接: (1)cd /etc/sysconfig/network-scripts/ #进入网络 ...
- sql-逻辑循环while if
--计算1-100的和 declare @int int=1; declare @total int=0; while(@int<=100) begin set @total=@total+@i ...
- Spark 0.9的安装配置
一.上传scala2.10.3到linux 下载scala 2.10.3文件.网上的scala-2.10.3.tgz.scala-2.10.3.rpm,前者支持unix,后者专门给linux使用.但我 ...
- 宿主进程 vshost.exe
Hosting Process (vshost.exe) 宿主进程是VS的一个特性.可以提高调试的性能,可以进行部分信任调试(partial trust debugging),可以进行设计时表达式计算 ...
- EXCEL 操作
1.为几万行数据加序号 先在A1,A2分别输入1,2,选中A1:A2,双击A2右下角那个小方块. 数据有多少行就会自动填充多少行(要求:B列数据连续) 2.统计一列中单元格的值等于某个值的单元格的个数 ...
- HDU5791--Two (DP)
题意:两个数列a,b,求相同的子序列有多少对,内容相同位置不同也算不同. 题解:dp[i][j]表示a数列前i个数个 b数列前j个数 有多少对 递推方程: dp[i][j] = dp[i-1][j-1 ...
- Umbraco中的权限体系结构
分为管理用户体系,和成员用户体系,也就是 Users(用户)和Members(成员). 2.1. Users(用户) 用户是对功能操作权限定义的,首先看一下所有Action的Permissions: ...
- 转载Sql 获取数据库所有表及其字段名称,类型,长度
转载原地址 http://www.cnblogs.com/Fooo/archive/2009/08/27/1554769.html SELECT (case when a.colorder=1 the ...
- cocos2d-x 3.0 开发(一) Hello_New_World
1.Previous On 2dx 2dx 的3.0版本是个与以往不同的版本.变化比2dx从1.x 到2.x的变化还要大不少.具体的新功能可以参见:CocoaChina大会见闻——cocos2 ...
- 浅析 ThreadLocal
一.ThreadLocal类说明 ThreadLocal,很容易让人望文生义,直译"本地线程".ThreadLocal不是一个thread,是thread的局部变量.使用Threa ...