知识储备
后端:JavaSE, SSM(Spring+SpringMVC+MyBatis)
前端:HTML, CSS, Javascript
环境准备
JDK17+下载
安装方式
IDEA安装
VS Code
MySQL8安装
创建Spring Boot项目
使用IDEA创建
使用IDEA引到界面创建项目


认识一下项目文件
porn.xml

Application启动文件
编写control文件

java
package com.geji.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "Hello World2~";
}
}
启动application文件

打开网页查看

手动创建
创建Maven工程


porn.xml引入依赖
sprint boot工程
XML
<!-- boot工程的父工程,起步依赖的版本管理 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.8</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

起步依赖
XML
<!--web起步依赖,没有写版本号,因为上面parent继承了-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

刷新porn.xml

编写启动类,改名字

编写启动文件
java
package com.geji;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Hello world!
*
*/
@SpringBootApplication
public class SpringBootCreateManuallyApplication
{
public static void main( String[] args )
{
SpringApplication.run(SpringBootCreateManuallyApplication.class,args);
}
}

创建resource目录

resource目录下创建application.properties

创建controller文件夹以及具体的文件
java
package com.geji.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "Hello World2~";
}
}

Spring Boot配置文件
propeties形式
修改端口号以及虚拟路径

打开网址验证效果

yaml形式

其他:yml文件的读取方式

另一种简单的方法
