- 导入初始化的文件夹
- 删除3个目录
- .mvn、mvnw、mcnw.cmd
- 添加 对web的依赖
- 编写 SpringMVC 的 controller。创建文件夹 controller,选中文件夹,复制 HelloController.java
- 运行,测试
<!--对于web的依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
pom.xml
package com.example.demo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping(value = "/hello",method = RequestMethod.GET)
public String helloSpringBoot(){
return "Hello SpringBoot!";
}
}
HelloController.java
运行
运行结果