Mybatis总结--针对读取properties文件的错误

在运行mybatis配置文件的时候,出现错误:The content of element type "configuration" must match   "(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,reflectorFactory?,plugins?,environments?,databaseIdProvider?,mappers?)".

当配置是下面这样的会提示你报错,因为他是安装严格的顺序来的,顺序不能乱了!

  1. xml version="1.0" encoding="UTF-8" ?>  
  2. "http://mybatis.org/dtd/mybatis-3-config.dtd">  
  3. <configuration>  
  4.     <properties resource="dbConfig.properties">properties>  
  5.     <environments default="development">  
  6.         <environment id="development">  
  7.             <transactionManager type="JDBC" />  
  8.             <dataSource type="POOLED">  
  9.                 <property name="driver" value="${driver}" />  
  10.                 <property name="url" value="${url}" />  
  11.                 <property name="username" value="${dbuser}" />  
  12.                 <property name="password" value="${dbpassword}" />  
  13.             dataSource>  
  14.         environment>  
  15.     environments>  
  16.     <mappers>  
  17.         <mapper resource="com/apps/dao/RemainDao.xml"/>   
  18.     mappers>  
  19.     <typeAliases>  
  20.         <typeAlias type="com.apps.domain.User" alias="_User"/>  
  21.     typeAliases>  
  22. configuration>  
把鼠标放到configuration上会看到给的顺(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,reflectorFactory?,plugins?,environments?,databaseIdProvider?,mappers?)".

  1. xml version="1.0" encoding="UTF-8" ?>  
  2. "http://mybatis.org/dtd/mybatis-3-config.dtd">  
  3. <configuration>  
  4.     <properties resource="dbConfig.properties">properties>  
  5.     <typeAliases>  
  6.         <typeAlias type="com.apps.domain.User" alias="_User"/>   
  7.     typeAliases>  
  8.     <environments default="development">  
  9.         <environment id="development">  
  10.             <transactionManager type="JDBC" />  
  11.             <dataSource type="POOLED">  
  12.                 <property name="driver" value="${driver}" />  
  13.                 <property name="url" value="${url}" />  
  14.                 <property name="username" value="${dbuser}" />  
  15.                 <property name="password" value="${dbpassword}" />  
  16.             dataSource>  
  17.         environment>  
  18.     environments>  
  19.     <mappers>  
  20.         <mapper resource="com/apps/dao/RemainDao.xml"/>  
  21.     mappers>     
  22. configuration>  


修改后就可以通过了!!!问题就解决了

你可能感兴趣的:(Mybatis总结)