摘要: SpringBoot默认使用Logback组件作为日志管理。LogBack是由log4j创始人设计的一个开源日志组件 在SpringBoot项目中我们不需要额外的添加Logback的依赖,因为spring-boot-starter或者spring-boot-starter-web中已经包含了Logb 阅读全文
posted @ 2020-08-28 13:45 lawrence林 阅读(280) 评论(0) 推荐(0) 编辑
摘要: 添加actuator依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> #/默认值访问healt 阅读全文
posted @ 2020-08-28 13:12 lawrence林 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑
摘要: SpringBoot项目中resources目录下的static 和 templates 两个文件夹用于存放静态资源 static一般存放静态页面,如html,css,js等 templates一般用于存放动态页面,一般用于存放Thymeleaf 静态文件存放于static目录下 <!DOCTYPE 阅读全文
posted @ 2020-08-28 12:40 lawrence林 阅读(176) 评论(0) 推荐(0) 编辑
摘要: #整合Servlet方式一(通过注解扫描完成Servlet组件的注册) 1.创建Serverlet 2.修改启动类,添加 @ServletComponentScan 添加web依赖 <dependency> <groupId>org.springframework.boot</groupId> <a 阅读全文
posted @ 2020-08-28 12:39 lawrence林 阅读(191) 评论(0) 推荐(0) 编辑
摘要: #版本介绍 通过官网网址:https://spring.io/projects/spring-boot 查看版本,如下 | 版本名称 | 意义 | | | | | SNAPSHOT | 快照版,就是还在开发阶段,不没有经过大量的测试,稳定性差,不建议使用 | | CURRENT | 最新版,但是不一 阅读全文
posted @ 2020-08-28 12:37 lawrence林 阅读(327) 评论(0) 推荐(0) 编辑