springboot和mybatis结合


https://blog.csdn.net/shengshenglalalala/article/details/100576106

遇到的问题

1 实体类日期格式化


pom依赖

        
        
            joda-time
            joda-time
            2.9.9
        
        
        
            com.fasterxml.jackson.core
            jackson-annotations
            2.8.8
        
        
            com.fasterxml.jackson.core
            jackson-databind
            2.8.8
        
        
            org.codehaus.jackson
            jackson-mapper-asl
            1.9.13
        

实体类中加

    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")//页面写入数据库时格式化
    @JsonFormat(pattern="yyyy-MM-dd HH:mm",timezone="GMT+8")//数据库导出页面时json格式化, timezone:是时间设置为东八区,避免时间在转换中有误差
    private Date e_updateTime;

时间完整格式

  yyyy-MM-dd HH:mm:ss SSS

2 Mybatis JdbcType与Oracle、MySql数据类型对应列表

jdbcType=TIMESTAMP
https://mybatis.org/mybatis-3/apidocs/reference/org/apache/ibatis/type/JdbcType.html

3 thymeleaf模板引擎

https://mp.weixin.qq.com/s/Uvv1q3iQn2IwAB1crHWS1g

4 lombok @Accessors 链式访问

@Accessors(chain=true) 链式访问 生成setter方法返回this(也就是返回的是对象),代替了默认的返回void。

https://www.jianshu.com/p/67a15b2e4a92

5 mybatis添加返回id

https://blog.csdn.net/qq_45085954/article/details/102781741
mybatis添加用户返回id
在添加用户时,常把一个表的id设为主键,自增,以至于再插入数据的时候,无法直接获取用户id,如果下面操作还需要用到id,那么还要通过查询来获取,浪费资源
selectKey标签


	        
    
        select last_insert_id()
    
    insert into t_user (name,gender,create_time)
    values(#{name},#{gender},#{createTime})


6 thymeleaf th:href 带多个参数

http://www.yayihouse.com/yayishuwu/chapter/1989


7 Tymplate if

通过session获取用户权限来判断button是否隐藏

        

8 Spring Boot 配置 Security 密码加密