首页 > 其他 > 详细

MP教程-配置

时间:2020-03-28 21:41:50      阅读:70      评论:0      收藏:0      [点我收藏+]

配置

一、Mybatis原生配置

  • application.properties


mybatis-plus.config-location=classpath:mybatis.xml

 

  • mybatis.xml


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

 

 

二、使用Mybatis的原生Mapper配置

  • application.properties

    
    
    mybatis-plus.mapper-locations=classpath*:mybatis/*.xml

     

    ?

  • UserMapper.xml

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE mapper
      PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
      "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper namespace="com.will.learn.springboot.mapper.UserMapper">
      <select id="selById" resultType="com.will.learn.springboot.pojo.User">
        select * from tb_user where id = #{id}
      </select>
    </mapper>

     

三、进阶配置

  • MyBatis别名包扫名路径配置


mybatis-plus.type-aliases-package = com.will.learn.springboot.pojo

 

  • DB策略配置(IdType)


mybatis-plus.global-config.db-config.id-type=auto

 

  • DB策略配置(tablePrefix)


mybatis-plus.global-config.db-config.table-prefix=tb_

 

MP教程-配置

原文:https://www.cnblogs.com/deepminer/p/12589523.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!