It only took two days to understand spring6! The latest detailed explanation of 2023【End】

officially released

Spring is an excellent lightweight open source framework, which is widely used in enterprise development due to its powerful functions and excellent performance. In November 2022, the release of the official version of Spring 6 marks the arrival of a new era.

new features

Let's take a look at what features this version 6.0 brings? It should be noted that the entire framework code base of this version is now based on the Java 17 source code level, so if you want to use it, you need to upgrade the version to JDK 17+, and the underlying J2EE has also been migrated to Jakarta EE 9 (at least Tomcat 10 / Jetty 11, for compatibility with Jakarta EE 9)

Spring officially believes that JDK11 is just a transitional version of JDK, while JDK17 is almost a brand new programming language that enhances and improves the API and JVM, which makes upgrading JDK17 a ​​more attractive option.

main content

The main updates are as follows:

  • Introduce builder API for AOT engine settings

  • Support Spring application to explore virtual threads, based on JDK19

  • Compile Spring applications into native images based on GraalVM

  • Migrate javax.servlet to jakarta.servlet, compatible with the latest web servers such as: Tomcat 10.1, Jetty 11, Undertow 2.3, the latest persistence framework Hibernate ORM 5.6.x

new function!

AOT compilation

Ahead-Of-Time, that is, pre-compiled, compared with the well-known Just-In-Time (JIT, just-in-time compilation), the benefit of AOT is that the JVM can directly load these class information that has been pre-compiled into binary code, which can be directly call without having to compile it into binary code at runtime. Because AOT does not take up running time, some time-consuming optimizations can be done, thereby significantly speeding up the startup of the program. Avoid compilation performance consumption and memory consumption when the program is running, and can achieve the highest performance in the early stage of program running.

The AOT method can reduce the warm-up time brought by JIT, and reduce the long-term feeling of "slow first run" brought by Java applications.

AOT的引入,意味着Spring生态正式引入了提前编译技术,相比于JIT编译,AOT有助于优化Spring框架启动慢、占用内存多、以及垃圾无法被回收等问题。

Spring Native

在新版本中引入了Spring Native,有了Spring Native ,Spring可以不再依赖Java虚拟机,而是基于 GraalVM 将 Spring 应用程序编译成原生镜像(native image),提供了一种新的方式来部署 Spring 应用,这种部署 Spring 的方式是云原生友好的。

Spring Native的优点是编译出来的原生 Spring 应用可以作为一个独立的可执行文件进行部署,而不需要安装JVM,而且启动时间非常短并且消耗更少的资源,它的缺点就是构建时长要比JVM更长一些。

Spring Framework 6.0.x 原生镜像支持的 GraalVM 版本是基于 JDK 17-19 的 GraalVM 22.3。请注意,截至 2023 年,GraalVM 与 OpenJDK 发布模型保持一致,每个新的 GraalVM 版本仅支持最新的 Java 级别。因此,Spring Framework 6.x 功能版本可能需要在未来需要具有更高 JDK 基线的新 GraalVM 版本,例如基于 JDK 21 作为下一个 LTS。

虚拟线程

众所周知当前Java线程的实现是每个Java线程需要消耗一个操作系统线程。而操作系统线程这种资源是非常稀缺,非常宝贵的。而虚拟线程是java.lang.Thread一种用户态的实现,当我们在虚拟线程上使用同步API时,是不会阻塞任何操作系统线程,硬件利用率接近最佳。

JDK19 正式引入虚拟线程,意味着许多虚拟线程可以在同一个操作系统线程上运行它们的 Java 代码,从而有效地共享它。值得一提的是,它能做到在几个G的JVM堆上创建几百万个活动的虚拟线程(这在现在的JDK中几乎不可能实现),并且表现出和现在的线程几乎一样的行为。这些协程由 JVM 管理,因此它们也不会增加额外的上下文切换开销,因为它们作为普通 Java 对象存储在 RAM 中。

总结

Spring 将 Spring 6.0 称为下一个十年的新开端,直接舍弃了以往版本的 JDK,强制升级到 JDK 17及以上。而目前国内市场上大部分公司还在使用 JDK 8,新应用你会使用 Spring 6.0 嘛?

学习教程

内容简介

本套教程采用Spring6正式版录制,既适合Java菜鸟,也适合Java老鸟。教程从基础讲起,由浅入深,通俗易懂,手把手教学,视频、代码、笔记、资料一应俱全,对菜鸟极其友好。同时深入IoC和AOP底层实现,手写框架实现IoC,老鸟可以进一步掌握Spring底层,做到手写Spring框架。

教程总计11个章节,内容涵盖IoC、AOP、JdbcTemplate、事务、Resources、i18n、Validation和AOT等,既有深度,也有广度,带你轻松从入门到精通Spring框架,学习后即可快速应用于实际项目开发,也能高效地武装到面试中!

教程目录

01.教程简介

02.概述-Spring是什么

03.概述-Spring狭义和广义划分

04.概述-SpringFramework特点

05.概述-Spring模块组成和版本要求

06.入门-入门案例实现步骤

07.入门-入门案例程序开发

08.入门-入门案例程序分析

09.入门-整合Log4j2日志框架(上)

10.入门-整合Log4j2日志框架(下)

11.容器:IoC-概述(上)

12.容器:IoC-概述(中)

13.容器:IoC-概述(下)

14.容器:IoC-基于XML管理Bean-环境搭建

15.容器:IoC-基于XML管理Bean

-获取Bean(上)

16.容器:IoC-基于XML管理Bean

-获取Bean(中)

17.容器:IoC-基于XML管理Bean

-获取Bean(下)

18.容器:IoC-基于XML管理Bean

-依赖注入-setter注入(上)

19.容器:IoC-基于XML管理Bean

-依赖注入-setter注入(下)

20.容器:IoC-基于XML管理Bean

-依赖注入-构造器注入

21.容器:IoC-基于XML管理Bean

-依赖注入-特殊值处理

22.容器:IoC-基于XML管理Bean

-依赖注入-特殊类型属性-准备

23.容器:IoC-基于XML管理Bean

-依赖注入-对象类型属性(上)

24.容器:IoC-基于XML管理Bean

-依赖注入-对象类型属性(中)

25.容器:IoC-基于XML管理Bean

-依赖注入-对象类型属性(下)

26.容器:IoC-基于XML管理Bean

-依赖注入-数组类型属性

27.容器:IoC-基于XML管理Bean

-依赖注入-List类型属性

28.容器:IoC-基于XML管理Bean

-依赖注入-Map类型属性

29.容器:IoC-基于XML管理Bean

-依赖注入-引入集合bean

30.容器:IoC-基于XML管理Bean

-依赖注入-p命名空间

31.容器:IoC-基于XML管理Bean

-引入外部属性文件

32.容器:IoC-基于XML管理Bean

-Bean作用域

33.容器:IoC-基于XML管理Bean

-bean生命周期(上)

34.容器:IoC-基于XML管理Bean

-bean生命周期(下)

35.容器:IoC-基于XML管理Bean

-FactoryBean

36.容器:IoC-基于XML管理Bean

-自动装配(准备)

37.容器:IoC-基于XML管理Bean

-自动装配(实现)

38.容器:IoC-基于注解管理Bean

-创建Bean对象

39.容器:IoC-基于注解管理Bean

-@Autowired注入(上)

40.容器:IoC-基于注解管理Bean

-@Autowired注入(中)

41.容器:IoC-基于注解管理Bean

-@Autowired注入(下)

42.容器:IoC-基于注解管理Bean

-@Resource注入

43.容器:IoC-基于注解管理Bean

-全注解开发

44.原理:手写IoC-回顾Java反射(上)

45.原理:手写IoC-回顾Java反射(中)

46.原理:手写IoC-回顾Java反射(下)

47.原理:手写IoC-实现步骤分析

48.原理:手写IoC-实现Bean创建(上)

49.原理:手写IoC-实现Bean创建(中)

50.原理:手写IoC-实现Bean创建(下)

51.原理:手写IoC-实现属性注入

52.面向切面:AOP-场景模拟

53.面向切面:AOP-代理模式(静态代理)

54.面向切面:AOP-代理模式(动态代理)

55.面向切面:AOP-AOP概念和术语

56.面向切面:AOP-基于注解的AOP

-步骤分析

57.面向切面:AOP-基于注解的AOP

-前置通知

58.面向切面:AOP-基于注解的AOP

-各种通知

59.面向切面:AOP-基于注解的AOP

-重用切入点和切面优先级

60.面向切面:AOP-基于XML的AOP

-五种通知类型

61.单元测试:

JUnit-Spring整合JUnit5和JUnit4

62.事务-JdbcTemplate-概述和准备

63.事务-JdbcTemplate

-实现CRUD操作(上)

64.事务-JdbcTemplate

-实现CRUD操作(下)

65.事务-基于注解的声明式事务

-搭建案例环境

66.事务-基于注解的声明式事务

-案例功能实现

67.事务-基于注解的声明式事务

-案例添加事务

68.事务-基于注解的声明式事务

-事务相关属性(上)

69.事务-基于注解的声明式事务

-事务相关属性(下)

70.事务-基于注解的声明式事务

-全注解配置事务

71.事务-基于XML的声明式事务-具体实现

72.资源操作:

Resources-Resource接口和实现类(上)

73.资源操作:

Resources-Resource接口和实现类(下)

74.资源操作:

Resources-ResourceLoader接口

75.资源操作:

Resources-ResourceLoaderAware接口

76.资源操作:

Resources-使用Resource作为属性

77.资源操作:Resources-指定访问策略

78.国际化:i18n-Java国际化

79.国际化:i18n-Spring国际化

80.数据校验:Validation

-通过Validator接口实现

81.数据校验:

Validation-bean Validation注解实现

82.数据校验:

Validation-基于方法实现校验

83.数据校验:Validation-自定义校验

84.提前编译:AOT-AOT概述

85.提前编译:AOT-Native Image构建(安装GraalVM编辑器)

86.提前编译:

AOT-Native Image构建(安装C++编译环境)

87.提前编译:

AOT-Native Image构建(实现构建)

88.教程总结

课程链接

吃透spring6只用了两天!2023最新详解【完结】

!!需要文档资料评论区领取!

Guess you like

Origin blog.csdn.net/wshyb0314/article/details/129203621