发表于: 2018-08-14 21:46:42
1 729
今日完成
使用 thymeleaf 模板时 ,出现 依赖 无法识别
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
导入 依赖 后, pom 文件 报错 , 依赖 无法加载
查看师兄 日报 ,尝试 在 properties 标签 导入 thymeleaf 版本
<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>
依旧 无法 加载; html 页面 也就无法 加载 ,导致 页面 出现 错误
学习 通用mapper 时候 会 使用 一些 注解去 标记 字段
由于 之前 没有 使用 过, 学 起来 有点慢
在 java 实体类 中 , 最简单 的 情况 ,只需要 一个 @Id 标记 字段为 主键
public class Country { @Id private Integer id; private String countryname; private String countrycode; //省略 getter 和 setter}
通用 Mapper 提供了大量的通用接口
public interface CountryMapper extends Mapper<Country> { }
只要配置 MyBatis 时能注册或者扫描到该接口,该接口提供的方法就都可以使用。
该接口默认继承的方法如下:
- selectOne
- select
- selectAll
- selectCount
- selectByPrimaryKey 等等
//从 MyBatis 或者 Spring 中获取 countryMapper,然后调用 selectAll 方法 List<Country> countries = countryMapper.selectAll();
也可以 增加 自己 的 方法在 接口中
通用 Mapper 中,默认情况下是将实体类字段按照驼峰转下划线形式的表名列名进行转换。
例如:实体类的 userName
可以映射到表的 user_name
上。
这里 有一些 注解 的 用法 还 需要 去 学习
如: @Table
注解(JPA);@Column
注解(JPA);@ColumnType
注解(Mapper);
@Transient
注解(JPA);@GeneratedValue
注解(JPA);@KeySql
注解
以及 lombok 的 @Data 注解
关于 代码生成器 mybatis-generator 生成 实体类 、接口 这个 常用吗?
二级缓存 ?
看了一下 springboot 使用 redis 缓存
Lettuce
Lettuce
和 Jedis
的都是连接Redis Server
的客户端程序。Jedis
在实现上是直连redis server
,多线程环境下非线程安全,除非使用连接池,为每个Jedis实例增加物理连接。Lettuce
基于Netty的连接实例(StatefulRedisConnection),可以在多个线程间并发访问,且线程安全,满足多线程环境下的并发访问,同时它是可伸缩的设计,一个连接实例不够的情况也可以按需增加连接实例。
扩展了 一些 关于 springboot 整合 使用 的 中间件、插件等 , 需要 一步一步 去 实现
评论