学习目标:
四大核心
学习内容:
提示:这里可以添加要学的内容
例如:
1、 自动配置(重要)
2、 起步依赖(重要)
3、 Actuator(健康检测,用不着)
4、命令行界面(了解,用不着)
学习时间:
提示:这里可以添加计划学习的时间
例如:
1、 周一至周五晚上 7 点—晚上9点
2、 周六上午 9 点-上午 11 点
3、 周日下午 3 点-下午 6 点
学习产出:
1.配置依赖和插件
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<!-- springboot必须设置parent标签-->
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.4.4</version>
</parent>
<dependencies>
<!-- web环境-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.4.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.4.4</version>
</plugin>
</plugins>
</build>
2.controller
package com.ky.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloController {
@RequestMapping("hello")
@ResponseBody
public String hello(){
return "hello";
}
}
3.Starter类
package com.ky;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Starter {
public static void main(String[] args) {
SpringApplication.run(Starter.class);
}
}
4.结果

本文将指导你深入理解Spring Boot,从自动配置开始,重点讲解依赖管理、Actuator健康检测的简化使用,以及创建基本的Web控制器。通过实例配置详解,助你快速上手Spring Boot 2.4.4。
1183

被折叠的 条评论
为什么被折叠?



