SpringBoot3

JDK****关注的新特性

搭建学习环境

有用的新特性

Java Record

看看Record怎么用

Instance Methods

静态方法****Static Method

Record****的构造方法

RecordLombok

Record****实现接口

Local Record

嵌套****Record

instanceof判断Record****类型

Switch

箭头表达式,新的case标签

yeild****返回值

java 复制代码
public static void main(String[] args) {
int week = 1;
//yield 是 switch 的返回值, yield 跳出当前 switch 块
String memo = switch (week){
case 1 ->{
System.out.println("week=1 的 表达式部分");
yield "星期日,休息";
}
case 2,3,4,5,6 ->{
System.out.println("week=2,3,4,5,6 的 表达式部分");
yield "工作日";
}
case 7 -> {
System.out.println("week=7 的 表达式部分");
yield "星期六,休息";
}
default -> {
System.out.println("其他语句");
yield "无效日期";
}
};
System.out.println("week = " + memo);
}

Java Record

Text Block

认识文本块

文本块与普通的双引号字符串一样

java 复制代码
public void fun1() {
String s1= """
lisi
""";
String s2 = """
lisi
""";
//比较字符串
boolean b1 = s1.equals(s2);
System.out.println("b1 = " + b1);
//使用 == 的比较
boolean b2 = s1 == s2;
System.out.println("b2 = " + b2);
String msg = """
hello world""";
//字符串方法 substring
String sub = msg.substring(0, 5);
System.out.println("sub = " + sub);
}

空白

文本块的方法

转义字符

var

var****声明局部变量

使用时候使用****var

sealed

Sealed Classes

java 复制代码
//第一种 final
public final class Circle extends Shape {
}
//第二种 sealed class
public sealed class Square extends Shape permits RoundSquare {
@Override
public void draw() {
System.out.println("=======Square 图形======");
}
}
//密封类的子类的子类
public final class RoundSquare extends Square{
}
//非密封类 , 可以被扩展。放弃密封
public non-sealed class Rectangle extends Shape {
}
//继承非密封类
public class Line extends Rectangle{
}

Sealed Interface

Spring Boot

Spring关系

SpringCloud关系

最新的Spring Boot3新特性

如何学好框架

脚手架

使用脚手架创建项目

IDEA创建SpringBoot****项目

代码结构

单一模块

多个模块

包和主类

spring-boot-starter-parent

运行Spring Boot项目方式

starter

外部化配置

相关推荐
one year.14 小时前
Linux:线程同步与互斥
java·开发语言
一 乐14 小时前
旅游|内蒙古景点旅游|基于Springboot+Vue的内蒙古景点旅游管理系统设计与实现(源码+数据库+文档)
开发语言·前端·数据库·vue.js·spring boot·后端·旅游
JaguarJack14 小时前
15 个 Eloquent 高级技巧,瞬间提升你的 Laravel 应用性能
后端·php·laravel
YDS82914 小时前
苍穹外卖 —— Spring Cache和购物车功能开发
java·spring boot·后端·spring·mybatis
苍老流年14 小时前
1. SpringBoot初始化器ApplicationContextInitializer使用与源码分析
java·spring boot·后端
星光一影14 小时前
基于SpringBoot智慧社区系统/乡村振兴系统/大数据与人工智能平台
大数据·spring boot·后端·mysql·elasticsearch·vue
劲墨难解苍生苦14 小时前
spring ai alibaba mcp 开发demo
java·人工智能
leonardee14 小时前
Spring 中的 @ExceptionHandler 注解详解与应用
java·后端
不爱编程的小九九14 小时前
小九源码-springboot103-踏雪阁民宿订购平台
java·开发语言·spring boot
Elieal14 小时前
Spring 框架核心技术全解析
java·spring·sqlserver