摘要: 1、添加DevTools依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency> 2、设置自动编译,勾选自动编译Bui 阅读全文
posted @ 2020-08-28 13:09 lawrence林 阅读(373) 评论(0) 推荐(0) 编辑
摘要: #SpringBoot对Controller中其他参数的校验 编写页面 对参数指定校验规则 在Controller中开启校验 通过全局异常处理来跳转页面 校验规则有Hibernate Validator提供,该校验规则由web起步依赖提供,如下: 修改实体类添加校验规则 /** * @NotNull 阅读全文
posted @ 2020-08-28 13:08 lawrence林 阅读(194) 评论(0) 推荐(0) 编辑
摘要: SpringBoot2.X使用Junit5作为测试平台 修改POM文件添加Test启动器 编写测试代码 从官网下载的项目和用idea教授叫工具创建的项目默认都有添加junit依赖 <dependency> <groupId>org.springframework.boot</groupId> <ar 阅读全文
posted @ 2020-08-28 13:03 lawrence林 阅读(135) 评论(0) 推荐(0) 编辑
摘要: #第一种:自定义错误页面 SpringBoot默认的处理异常的机制:SpringBoot默认的已经提供了一套处理异常的机制。 一旦程序中出现了异常SpringBoot会向/error的url发送请求。 SpringBoot中提供了一个名为BasicErrorController来处理/error请求 阅读全文
posted @ 2020-08-28 13:02 lawrence林 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 步骤 搭建项目环境 创建项目 修改POM文件,添加相关依赖 配置数据源 POM文件 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </ 阅读全文
posted @ 2020-08-28 12:57 lawrence林 阅读(145) 评论(0) 推荐(0) 编辑
摘要: #第一种,通过自定义配置文件方式配置数据源信息 添加相关依赖 <!--thymeleaf启动器--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf< 阅读全文
posted @ 2020-08-28 12:55 lawrence林 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 步骤 创建项目 修改POM文件,添加Thymeleaf启动器依赖 创建Controller 创建视图 添加依赖 <!--添加Thymeleaf启动器依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>s 阅读全文
posted @ 2020-08-28 12:53 lawrence林 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 步骤 创建项目 修改POM文件,添加Freemarker启动器 创建Controller 创建Users实体 添加Freemarker文件配置 创建视图 Freemarker也是视图层技术,与Thymeleaf相似,他们都被称为模板视图 添加Freemarker依赖 <!--Freemarker启动 阅读全文
posted @ 2020-08-28 12:50 lawrence林 阅读(137) 评论(0) 推荐(0) 编辑
摘要: 步骤 创建项目 修改POM文件,添加JSP引擎与JSTL标签库 创建webapp目录 标记为web目录 创建jsp 注意:在springboot项目中是不推荐使用jsp作为视图层技术的 JSP是在tomcat里面编译、运行的; 以往的web项目是将项目部署的tomcat容器当中,tomcat负责将J 阅读全文
posted @ 2020-08-28 12:44 lawrence林 阅读(211) 评论(0) 推荐(0) 编辑
摘要: 步骤 POM文件 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org 阅读全文
posted @ 2020-08-28 12:42 lawrence林 阅读(170) 评论(0) 推荐(0) 编辑