spring boot 整合JdbcTemplate 踩坑记录

      今天学习spring boot ,看了以下这篇博客。

      https://www.cnblogs.com/sam-uncle/p/8805741.html

      练手时出现了BUG,特以此博客作为记录。

       第一个BUG:

                             原文截图:     spring boot 整合JdbcTemplate 踩坑记录

         进行测试时STS控制台报红:

spring boot 整合JdbcTemplate 踩坑记录

上网一搜,原来如此。(此方法的博客来源: https://www.cnblogs.com/21heshang/p/6369796.html )

spring boot 整合JdbcTemplate 踩坑记录

按照它的这样一改,没问题。(我改成useSSL=false)

spring boot 整合JdbcTemplate 踩坑记录

思考:

(1)项目执行时是从

                                 请求 --->

                                 Controller --->

                                 (实体类用来保存页面输入的数据、参数) --->
                                 Service  ---> 

           (ServiceImpl上面有个@Service的注解,以及 implements 某个Service 这样子,spring就知道这个实现类是实现谁了,即使名字不同也没关系)

                                  dao --->

spring boot 整合JdbcTemplate 踩坑记录

         (  JdbcTemplate 的舞台在DAO层,在org.springframework.jdbc.core.JdbcTemplate包,用的时候开发工具会提示包导入的 )                 

           最后,写库存档。

(2)开发时顺序就和项目执行的流程顺序反过来。

           先建好数据库、表之类的。

           然后造实体类。(最好和数据库的表对应吧)

           写SQL语句(打理DAO层)

          定义Service接口,以及写实现类的具体逻辑。

           最上层,控制层。

        (层与层之间通过调用,使得它们有了关系,如下列图展示了service.save()方法所走过的路,执行完之后到了return语句,结果就是最后一张图。)

spring boot 整合JdbcTemplate 踩坑记录

spring boot 整合JdbcTemplate 踩坑记录

spring boot 整合JdbcTemplate 踩坑记录

spring boot 整合JdbcTemplate 踩坑记录

由JdbcTemplate 这个类把SQ语句执行

spring boot 整合JdbcTemplate 踩坑记录

执行完,如上图结果。