Java技术栈 —— 微服务框架Spring Cloud —— Ruoyi-Cloud 学习(二)

参考视频或文章链接
RuoYi-Cloud官方文档
《若依框架讲解-微服务版》- bilibili
《若依框架讲解-微服务版》课件 — 提取码 8888
《JWT及鉴权》— 骄傲的演员 — CSDN

一、登录功能(鉴权模块)

假如我是RuoYi项目的开发者,我应该怎么样从无到有的把这个项目搭建起来?或者说我要先开发什么功能,因为一开始我对这个项目要划分成哪些模块是模糊的,所以先从具体的功能入手,等有了大量的项目阅历,就知道这个项目要如何划分模块,如何进行架构了,先开发最常用的用户登录功能。我不打算完全照抄RuoYi的代码,而是在其基础上做些改动开发自己的功能,但模块甚至命名都会参考RuoYi。
验证码部分是在网关内部直接处理的。

1.1 后端部分

1.1.1 什么是JWT?

(1) Single Sign On is a feature that widely uses JWT nowadays, because of its small overhead and its ability to be easily used across different domains.
(2) In authentication, when the user successfully logs in using their credentials, a JSON Web Token will be returned. Since tokens are credentials, great care must be taken to prevent security issues. In general, you should not keep tokens longer than required.
(3) Whenever the user wants to access a protected route or resource, the user agent should send the JWT, typically in the Authorization header using the Bearer schema.

在这里插入图片描述

1.The application or client requests authorization to the authorization server. This is performed through one of the different authorization flows. For example, a typical OpenID Connect compliant web application will go through the /oauth/authorize endpoint using the authorization code flow.
2.When the authorization is granted, the authorization server returns an access token to the application.
3.The application uses the access token to access a protected resource (like an API).

参考视频或文章链接
JWT - offical website
《JWT及鉴权》— 骄傲的演员 — CSDN

1.1.2 什么是Base64?为什么需要它?

(1) Base64 allows you to transport binary over protocols or mediums that cannot handle binary data formats and require simple text.

参考视频或文章链接
Base64 encoding: What sysadmins need to know — RedHat
Base64 — Wiki

1.1.3 SpringBoot注解解析

我以为,注解@Annoation最重要的作用是提醒编译器,或者说提醒JVM虚拟机,带上注解@Annoation的这些类、方法、变量有哪些地方是要重点检查与注意的。

注解名称作用参考文章
@RestController结合了@Controller and @ResponseBody两个注解,简化了配置,Every request handling method of the controller class automatically serializes return objects into HttpResponse.The Spring @Controller and @RestController Annotations
@Autowired若不指定注入类名,根据变量名自动注入Guide to Spring @Autowired
@PostMapping
@RequestBody
@SpringBootApplication=@Configuration + @EnableAutoConfiguration + @ComponentScan18. Using the @SpringBootApplication Annotation

1.1.4 依赖注入和控制反转

两个词是一体两面的说法,控制反转,即将对象的控制权交给Spring容器,而以前的传统方式是程序员手工控制。

参考视频或文章链接
《控制反转及注入依赖详情「通俗易懂」》

1.1.5 什么是Restful?

一种设计风格,使用HTTP 协议传输数据,并通过URL来标识资源的位置和状态。

(1) Resource identification through URI. In the REST architectural style, data and functionality are considered resources and are accessed using Uniform Resource Identifiers (URIs), typically links on the Web.
(2) Uniform interface. Resources are manipulated using a fixed set of four create, read, update, delete operations: PUT, GET, POST, and DELETE.

参考视频或文章链接
What Are RESTful Web Services? —— The Java EE 6 Tutorial
RESTful Web Services —— GeeksForGeeks
《图文详解 RESTful》—— CSDN

1.1.6 Log4j 2、Logpack、SLF4j日志框架

《Java技术栈 —— Log4j 2、Logpack、SLF4j日志框架介绍》

1.1.7 如何将项目打包成指定bytecode字节码版本?

首先,要知道在Maven发明以前,也是可以打jar包的,所以肯定有两种方式,方式一是原生的方式,这里可以直接利用IDEA,更加便利,方式二是使用Maven,开始。

1.1.7.1 方式一(原生)

原生方式是采用Build Artifacts方式建立jar包(Artifacts = Art艺术 + ifacts事实 = 手工物品),如果不会用Build Artifacts构建jar包,请搜索其它文章,这里要说的是,原生方式下,怎么指定字节码版本。

Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Per-module bytecode version -> 指定module的版本

1.1.7.1 方式二(Maven)

source指.java源码文件是按何种Java版本编写的
target指.class字节码文件是以何种字节码版本生成的,这个很好理解。

    <properties>
        <maven.compiler.source>6</maven.compiler.source> <!--这里修改后再mvn reload,即影响Project Structure/Modules/Sources-->
        <maven.compiler.target>6</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

1.1.8 依赖包字节码版本不同,如何编译至相同版本?

A包是55.0字节码版本,B包是52.0字节码版本,你想将项目最终编译成52.0,在中国这片土地上,52.0是最常用的了,我想变革的阻力会随着信创产业的推进而降低,老守旧有什么意思?还是说能够带来稳定收益,守旧就可以了,不想着怎么去让架构更优,运行更稳定,更快?听说连JDK都要国产化?

参考视频或文章链接
《JDK 版本和字节码版本对应表》
IDEA —— Project language level

有了问题1.1.7的基础,如果你有完整项目源码,可以重新编译到指定字节码版本,这很简单。

假设你现在有一个依赖的jar包是字节码50.0的,并且只有jar包,没有源码,你想将项目整体重新编译至52.0,如何操作?抱歉,依赖包完整打好包那刻起就决定了,无法重新再编译至其它字节码版本。

假设你现在有一个依赖的jar包是字节码52.0的,并且只有jar包,没有源码,你想将项目整体重新编译至50.0,如何操作?抱歉,依赖包完整打好包那刻起就决定了,无法重新再编译至其它字节码版本。

1.1.9 如何照猫画虎,把项目A的依赖添加到项目B中?

很多时候,由于依赖是嵌套的太深,项目中的maven引用坐标也嵌套的很深,这个时候用IDEA的工具查看,找到maven/Analyze Dependencies即可,根据这里的指示,把maven的引用坐标添加到B项目中即可。
在这里插入图片描述

1.1.10 SpringBoot如何配置https

SpringBoot与SpringCloud项目的区别到底是什么?从项目结构上完全看不出区别,都有子模块,并且子模块之间可以相互依赖,从依赖上能看出区别?因为SpringCloud有依赖gateway这样字眼的jar包。

参考文章或视频链接
[1] Securing Spring Boot Applications With SSL
[2] How to Enable HTTPs in Spring Boot Application?
[3] 《使用SpringBoot配置https(SSL证书)》


1.2 前端部分

1.2.1 快速上手Vue

如果不知道如何安装和使用Vue搭建项目,请看参考文章[1]。

参考视频或文章链接
[1]《前端技术栈 —— Vue框架 —— (一)快速上手》
  • 21
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值