springboot的学习(1)
文章转载:(2条消息) Spring Boot 2 学习笔记(1 / 2)_KISS-CSDN博客
Spring Boot 2 学习笔记(2 / 2)
- | - | - |
---|---|---|
01、基础入门-SpringBoot2课程介绍 | 02、基础入门-Spring生态圈 | 03、基础入门-SpringBoot的大时代背景 |
04、基础入门-SpringBoot官方文档架构 | 05、基础入门-SpringBoot-HelloWorld | 06、基础入门-SpringBoot-依赖管理特性 |
07、基础入门-SpringBoot-自动配置特性 | 08、底层注解-@Configuration详解 | 09、底层注解-@Import导入组件 |
10、底层注解-@Conditional条件装配 | 11、底层注解-@ImportResource导入Spring配置文件 | 12、底层注解-@ConfigurationProperties配置绑定 |
13、自动配置【源码分析】-自动包规则原理 | 14、自动配置【源码分析】-初始加载自动配置类 | 15、自动配置【源码分析】-自动配置流程 |
16、最佳实践-SpringBoot应用如何编写 | 17、最佳实践-Lombok简化开发 | 18、最佳实践-dev-tools |
19、最佳实践-Spring Initailizr | 20、配置文件-yaml的用法 | 21、配置文件-自定义类绑定的配置提示 |
22、web场景-web开发简介 | 23、web场景-静态资源规则与定制化 | 24、web场景-welcome与favicon功能 |
25、web场景-【源码分析】-静态资源原理 | 26、请求处理-【源码分析】-Rest映射及源码解析 | 27、请求处理-【源码分析】-怎么改变默认的_method |
28、请求处理-【源码分析】-请求映射原理 | 29、请求处理-常用参数注解使用 | 30、请求处理-@RequestAttribute |
31、请求处理-@MatrixVariable与UrlPathHelper | 32、请求处理-【源码分析】-各种类型参数解析原理 | 33、请求处理-【源码分析】-Servlet API参数解析原理 |
34、请求处理-【源码分析】-Model、Map原理 | 35、请求处理-【源码分析】-自定义参数绑定原理 | 36、请求处理-【源码分析】-自定义Converter原理 |
37、响应处理-【源码分析】-ReturnValueHandler原理 | 38、响应处理-【源码分析】-HTTPMessageConverter原理 | 39、响应处理-【源码分析】-内容协商原理 |
40、响应处理-【源码分析】-基于请求参数的内容协商原理 | 41、响应处理-【源码分析】-自定义MessageConverter | 42、响应处理-【源码分析】-浏览器与PostMan内容协商完全适配 |
43、视图解析-Thymeleaf初体验 | 44、web实验-后台管理系统基本功能 | - |
01、基础入门-SpringBoot2课程介绍
Spring Boot 2核心技术
Spring Boot 2响应式编程
- 学习要求
-熟悉Spring基础
-熟悉Maven使用 - 环境要求
- Java8及以上
- Maven 3.3及以上
- 学习资料
- Spring Boot官网
- Spring Boot官方文档
- 本课程文档地址
- 视频地址1、视频地址2
- 源码地址
02、基础入门-Spring生态圈
Spring能做什么
Spring的能力
Spring的生态
覆盖了:
- web开发
- 数据访问
- 安全控制
- 分布式
- 消息服务
- 移动开发
- 批处理
- …
Spring5重大升级
- 响应式编程
- 内部源码设计
基于Java8的一些新特性,如:接口默认实现。重新设计源码架构。
为什么用SpringBoot
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”.link
能快速创建出生产级别的Spring应用。
SpringBoot优点
Create stand-alone Spring applications
- 创建独立Spring应用
Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
- 内嵌web服务器
Provide opinionated ‘starter’ dependencies to simplify your build configuration
- 自动starter依赖,简化构建配置
Automatically configure Spring and 3rd party libraries whenever possible
- 自动配置Spring以及第三方功能
Provide production-ready features such as metrics, health checks, and externalized configuration
- 提供生产级别的监控、健康检查及外部化配置
Absolutely no code generation and no requirement for XML configuration
- 无代码生成、无需编写XML
SpringBoot是整合Spring技术栈的一站式框架
SpringBoot是简化Spring技术栈的快速开发脚手架
SpringBoot缺点
- 人称版本帝,迭代快,需要时刻关注变化
- 封装太深,内部原理复杂,不容易精通
03、基础入门-SpringBoot的大时代背景
微服务
In short, the microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies.——James Lewis and Martin Fowler (2014)
- 微服务是一种架构风格
- 一个应用拆分为一组小型服务
- 每个服务运行在自己的进程内,也就是可独立部署和升级
- 服务之间使用轻量级HTTP交互
- 服务围绕业务功能拆分
- 可以由全自动部署机制独立部署
- 去中心化,服务自治。服务可以使用不同的语言、不同的存储技术
分布式
分布式的困难
- 远程调用
- 服务发现
- 负载均衡
- 服务容错
- 配置管理
- 服务监控
- 链路追踪
- 日志管理
- 任务调度
- …
分布式的解决
- SpringBoot + SpringCloud
云原生
上云的困难
- 服务自愈
- 弹性伸缩
- 服务隔离
- 自动化部署
- 灰度发布
- 流量治理
- …
上云的解决
04、基础入门-SpringBoot官方文档架构
官网文档架构
05、基础入门-SpringBoot-HelloWorld
系统要求
Maven配置文件
<mirrors>
<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
</mirrors><profiles>
<profile>
<id>jdk-1.8</id><activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation><properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
server:
servlet:
context-path: /app #设置应用名
这个设置后,URL要插入/app
, 如http://localhost:8080/app/hello.html
。
基本语法
表达式
表达式名字 | 语法 | 用途 |
---|---|---|
变量取值 | ${…} | 获取请求域、session域、对象等值 |
选择变量 | *{…} | 获取上下文对象值 |
消息 | #{…} | 获取国际化等值 |
链接 | @{…} | 生成链接 |
片段表达式 | ~{…} | jsp:include 作用,引入公共页面片段 |
字面量
- 文本值: ‘one text’ , ‘Another one!’ ,…
- 数字: 0 , 34 , 3.0 , 12.3 ,…
- 布尔值: true , false
- 空值: null
- 变量: one,two,… 变量不能有空格
文本操作
- 字符串拼接: +
- 变量替换: |The name is ${name}|
数学运算
- 运算符: + , - , * , / , %
布尔运算
- 运算符: and , or
- 一元运算: ! , not
比较运算
- 比较: > , < , >= , <= ( gt , lt , ge , le )
- 等式: == , != ( eq , ne )
条件运算
- If-then: (if) ? (then)
- If-then-else: (if) ? (then) : (else)
- Default: (value) ?: (defaultvalue)
特殊操作
- 无操作: _
属性优先级
Order | Feature | Attributes |
---|---|---|
1 | Fragment inclusion |
th:insert th:replace
|
2 | Fragment iteration |
th:each
|
3 | Conditional evaluation |
th:if th:unless th:switch th:case
|
4 | Local variable definition |
th:object th:with
|
5 | General attribute modification |
th:attr th:attrprepend th:attrappend
|
6 | Specific attribute modification |
th:value th:href th:src ...
|
7 | Text (tag body modification) |
th:text th:utext
|
8 | Fragment specification |
th:fragment
|
9 | Fragment removal |
th:remove
|
官方文档 - 10 Attribute Precedence
44、web实验-后台管理系统基本功能
项目创建
登陆页面
/static 放置 css,js等静态资源/templates/login.html 登录页<html lang="en" xmlns:th="http://www.thymeleaf.org"><!-- 要加这玩意thymeleaf才能用 --><form class="form-signin" action="index.html" method="post" th:action="@{/login}">...<!-- 消息提醒 --> <label style="color: red" th:text="${msg}"></label><input type="text" name="userName" class="form-control" placeholder="User ID" autofocus> <input type="password" name="password" class="form-control" placeholder="Password"><button class="btn btn-lg btn-login btn-block" type="submit"> <i class="fa fa-check"></i> </button>...</form>
/templates/main.html
主页
thymeleaf内联写法:
<p>Hello, [[${session.user.name}]]!</p>
登录控制层
@Controller
public class IndexController {
/**
* 来登录页
* @return
*/
@GetMapping(value = {"/","/login"})
public String loginPage(){return "login";
}@PostMapping("/login")
public String main(User user, HttpSession session, Model model){ //RedirectAttributesif(StringUtils.hasLength(user.getUserName()) && "123456".equals(user.getPassword())){
//把登陆成功的用户保存起来
session.setAttribute("loginUser",user);
//登录成功重定向到main.html; 重定向防止表单重复提交
return "redirect:/main.html";
}else {
model.addAttribute("msg","账号密码错误");
//回到登录页面
return "login";
}
}/**
* 去main页面
* @return
*/
@GetMapping("/main.html")
public String mainPage(HttpSession session, Model model){//最好用拦截器,过滤器
Object loginUser = session.getAttribute("loginUser");
if(loginUser != null){
return "main";
}else {
//session过期,没有登陆过
//回到登录页面
model.addAttribute("msg","请重新登录");
return "login";
}
}}
模型
@AllArgsConstructor
@NoArgsConstructor
@Data
public class User {
private String userName;
private String password;
}
springboot的学习(1)相关推荐
- 8. SpringBoot基础学习笔记
SpringBoot基础学习笔记 课程前置知识说明 1 SpringBoot基础篇 1.1 快速上手SpringBoot SpringBoot入门程序制作 1.2 SpringBoot简介 1.2.1 ...
- SpringBoot基础学习之SpringBoot配置(上篇)
前言: 小伙伴们,大家好,我是狂奔の蜗牛rz,当然你们可以叫我蜗牛君,我是一个学习Java半年多时间的小菜鸟,同时还有一个伟大的梦想,那就是有朝一日,成为一个优秀的Java架构师. 这个SpringB ...
- SpringBoot基础学习之整合Swagger框架(上篇)
前言: 小伙伴们,大家好,我是狂奔の蜗牛rz,当然你们可以叫我蜗牛君,我是一个学习Java半年多时间的小菜鸟,同时还有一个伟大的梦想,那就是有朝一日,成为一个优秀的Java架构师. 这个SpringB ...
- SpringBoot入门学习(六)之云收藏项目
目录 1.Spring Boot的思维导图分析 2.项目介绍 3.项目分析 4.创建SpringBoot项目,添加依赖 5.数据库 6.特别说明 7.效果展示 8.源码下载地址 本篇文章是Spring ...
- 《SpringBoot框架学习二之HTTP协议》
<SpringBoot框架学习二之HTTP协议> 文章目录 <SpringBoot框架学习二之HTTP协议> 一.HTTP介绍 (1)概述 (2)HTTP版本协议 1.HTTP ...
- 【SpringBoot】最新版2019Spring Boot配置解析,源码解析(速成SpringBoot)——学习笔记版【2】
SpringBoot配置文件 文章目录 SpringBoot配置文件 四.配置文件 1.简介 2.YAML用法 2.1 简介 2.2语法 3.为属性注入值 3.1使用.yml配置文件 3.1编写.ym ...
- SpringBoot入门学习(五)之旅游网站项目
目录 1.项目需求 2.技术需求 3.pom.xml 4.application.yml 4.MybatisPlus的配置文件 5.springboot中配置日期类型转换器 6.用户管理 7.线路管理 ...
- SpringBoot基础学习之整合SpringSercurity框架
前言: 小伙伴们,大家好,我是狂奔の蜗牛rz,当然你们可以叫我蜗牛君,我是一个学习Java半年多时间的小菜鸟,同时还有一个伟大的梦想,那就是有朝一日,成为一个优秀的Java架构师. 这个SpringB ...
- 项目记录(1)---SpringBoot的学习
SpringBoot 0.学习目标 了解SpringBoot的作用 掌握java配置的方式 了解SpringBoot自动配置原理 掌握SpringBoot的基本使用 了解Thymeleaf的基本使用 ...
- SpringBoot+Shiro学习(一):主要模块介绍
这篇文章是我最近对SpringBoot+Shiro+mybatis+redis一个练手项目的记录. 我是按照慕课网的一篇课程+百度进行练手的 慕课课程 练手项目Github地址 跟着开涛学Shiro ...
最新文章
- php oauth2.0 实例,详解laravel passport OAuth2.0的4种模式
- 微软计划使用 Rust 取代 C和C+
- Codeforces Round #505 D. Recovering BST(区间DP)
- 螺钉装弹垫平垫机器人_一种批量组装螺钉、弹垫、平垫的工装及使用方法_2
- Springboot整合RocketMQ实战
- python中字符串str的strip()方法
- python连接php_PHP+Python,轻量维护超轻松
- javascript小技巧(转自DooIT)http://www.cnblogs.com/ttyp/archive/2004/11/15/63900.html
- 正则表达式替换文本前n字符
- CSDN创始人董事长蒋涛对话阿里云张献涛:距离云计算终极目标还有多远?
- 9月TIOBE编程语言排行榜出炉,这个语言或成最大赢家!
- eclipse debug 多线程
- map和set的异同
- 未明学院:都知道智商、情商、逆商,可你知道“搜商”吗?
- python猜数字统计游戏次数_猜数字游戏的实现(Python3.5)
- kubernetes 实用 api list
- Linux服务器程序规范化
- nit报名费用计算机基础,2015年NIT计算机应用基础考试:Windows基本操作(Windows 7)...
- IntelliJ IDEA上debug模式启动
- 使用SPSS进行多元回归分析
热门文章
- 已知 XYZ+YZZ=532,其中,X、Y、Z 为数字,编程求出 X、Y 和 Z 的值。
- UCF Local Programming Contest 2018题解
- 龙之谷怎么进去服务器维护,龙之谷端游服务器爆满怎么进
- 证件照蓝底变白底的方法
- C#编写中英文虚拟键盘
- 项目管理知识体系指南 (八)
- 99计数器c语言,数字显示00-99计数器
- “我 33岁,阿里程序员,税后年薪170万,不配征婚?”
- Microsoft Excel 教程:如何在 Excel 中创建图表?
- innodb_buffer_pool_reads、innodb_buffer_pool_read_requests分析与innodb 缓存命中率计算