一、设置自增id

  1. 在navicat设计表里面把主键id设为自动递增
  2. mapper.xml在insert的语句加useGeneratedKeys=”true” keyProperty=”id”这两个属性

    1. <insert id="insertErrorLog" parameterType="ErrorLog" useGeneratedKeys="true" keyProperty="id">
    2. insert into sys_log(method,url,params,create_date,create_by)
    3. values (#{method},#{url},#{params},#{createDate},#{createBy})
    4. </insert>

    二、数据查询映射

  3. 如果符合驼峰命名原则,可以使用在application.properties里加上

mybatis.configuration.map-underscore-to-camel-case: true
就不用写别名了

三、新版本idea没有xml文件

在Settings->Editor->File and Code Templates里增加xml文件
image.png