mybatis 配置踩坑

Mybatis 踩坑

url 常见配置

url: jdbc:mysql://localhost:3306/database?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true

yml 文件配置

mybatis:
  config-location: classpath:mybatis\mybatis-config.xml
  mapper-locations: classpath*:mybatis\mapper\*.xml

这里的 classpath* 很重要!!!!! classpath 会出现错误,而阿里学习视频中这样配没问题!!!!

在配置文件中开启驼峰命名规则

mybatis.configuration.map-underscore-to-camel-case=true

在当前 mapper 中引入其他的 mapper 中的语句

引入的时候必须用全名,也就是包含 namespace + id 就可以直接引用了

例如:

<resultMap id="AllUserInfo" type="com.dwm.wxapplets.entity.SysUser">
        <association property="sysAddress" column="openId" select="com.dwm.wxapplets.mapper.SysAddressMapper.query"/>
</resultMap>
posted @ 2020-12-02 15:31  zolmk  阅读(132)  评论(0编辑  收藏  举报