最近看着身边的朋友都在搞springboot关联的东西,所以做了个DEMO试试,看看对比一下与之前springmvc的差别在哪,

DEMO目录结构:

springboot+mybatis+freemarker简单整合

配置文件: 简单点 说话的方式简单点,你又不是个演员 

springboot+mybatis+freemarker简单整合

Controller:大致的用法没什么区别,GetMapping == RequestMapping("/XX")这个地方也是简写,默认为get请求所以没有加method 也就是说在这里它已经将get与post请求分成两种注释来进行分别为 GetMapping 和PostMapping

springboot+mybatis+freemarker简单整合

Service:一个DEMO而已根本用不到这个好吗,当然也写了,只是觉得没有必要所以就过滤掉吧。

Dao: 这里整合了mybatis ,并且为注解方式进行,@Mapper这个注解估计大家一看就懂了,不懂的mapper.xml见过没有

S I D U这四个方法的注解都有 原始的标准SQL OK了。

springboot+mybatis+freemarker简单整合

页面:

springboot+mybatis+freemarker简单整合

springboot+mybatis+freemarker简单整合

根据yml配置文件里面定义的模板路径就可以了。

效果:

springboot+mybatis+freemarker简单整合

springboot+mybatis+freemarker简单整合

相关文章: