Mybatis取别名问题

今天学习Mybatis时在取别名这里总是报错,如图所示

  • 错误信息:

Cause: org.apache.ibatis.builder.BuilderException: Error creating document instance. Cause: org.xml.sax.SAXParseException; lineNumber: 36; columnNumber: 17; 元素类型为 “configuration” 的内容必须匹配 “(properties?,settings?,typeAliases?,typeHandlers?,objectFactory?,objectWrapperFactory?,reflectorFactory?,plugins?,environments?,databaseIdProvider?,mappers?)”。
Mybatis取别名问题_第1张图片

最后发现只需要在定义别名的时候把typeAlias标签放在properties标签后面就好了



<configuration>
    
    <properties resource="jdbcConfig.properties">
    properties>
    <typeAliases>
        <package name="domain">package>
    typeAliases>
    
    <environments default="mysql">
        
        <environment id="mysql">
            
            <transactionManager type="JDBC">
            transactionManager>
            
            <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>
    
    <mappers>
        <package name="dao"/>
    mappers>
configuration>

之后运行就正常了

在这里插入图片描述

你可能感兴趣的:(Mybatis)