0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

第一章 SpringBoot项目搭建

Last updated at Posted at 2025-01-09

创建SpringBoot项目

1.创建方法:

官网:https://start.spring.io/
image.png
点击完成后会自动下载一个压缩包→解压→用IDEA打开即可。
注意:SpringBoot不需要配置容器,使用了嵌入式容器,默认使用tomcat启动,默认端口8080。(容器:用于启动java web项目)

2.项目初始配置:

⭐编码配置:
image.png
⭐JDK配置:
image.png
⭐Maven配置:
image.png
⭐Git配置:
image.png

3.开发Hello World接口

⭐注解:
①ResponseBody:用于声明返回文本数据,一般返回JSON
②RestController:Controller层的注解(Controller层用于定义接口,是请求的入口)
③RequestMapping:要让方法变成一个接口(支持所有的请求方式)
常见的http请求方式:get查询 post新增 put修改 delete删除
④ComponentScan:配置要交给Spring管理的类路径
SpringBootApplication注解包含了ComponentScan注解
如果启动类和其它类所在的包没有包含关系的话,需要加ComponentScan注解
注意:扫描的路径不要太通用,比如扫描"com.jiawa",而不是"com"(会把第三方jar里的类也扫描出来)
image.png
注意:config层用于放配置类

4.自定义配置项

image.png

5.集成热部署

①在pom文件中添加依赖
image.png

image.png

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?