欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Mybatis配置文件

程序员文章站 2022-07-13 16:58:14
...

 今天发现Mybaits的配置文件校验很诡异,节点的位置还有要求

 

 

如下,会报错:

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

 

<?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">
<configuration>

	
    <environments default="development">
	    <environment id="development">
		    <transactionManager type="JDBC"/>
			<dataSource type="POOLED">
				<property name="driver" value="oracle.jdbc.driver.OracleDriver"/>
				<property name="url" value="jdbc:oracle:thin:@xx:1521:xx"/>
				<property name="username" value="ireport"/>
				<property name="password" value="xxxx"/>
			</dataSource>
	    </environment>
    </environments>
    
	<typeAliases>
	   <typeAlias type="com.ice.stat.online.model.EventFlag" alias="EventFlag"/>
	</typeAliases>
	
    <mappers>
	   <mapper resource="com/ice/stat/online/model/hbm/EventFlagMapper.xml"/>
	</mappers>
	
</configuration>
 

把typeAliases放到最上面就好了说:

<?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">
<configuration>
	<typeAliases>
	   <typeAlias type="com.ice.stat.online.model.EventFlag" alias="EventFlag"/>
	</typeAliases>
	
    <environments default="development">
	    <environment id="development">
		    <transactionManager type="JDBC"/>
			<dataSource type="POOLED">
				<property name="driver" value="oracle.jdbc.driver.OracleDriver"/>
				<property name="url" value="jdbc:oracle:thin:@xx:1521:xx"/>
				<property name="username" value="ireport"/>
				<property name="password" value="xxxx"/>
			</dataSource>
	    </environment>
    </environments>
    
	
    <mappers>
	   <mapper resource="com/ice/stat/online/model/hbm/EventFlagMapper.xml"/>
	</mappers>
	
</configuration>
 
相关标签: Mybatis