近日学习spring boot,书以记之。
最终项目结构为
1 创建项目
其余不赘述,在Dependencies一页,选择web,如图
2 创建controller并访问
controller代码
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class UserController {
@RequestMapping("/hello")
public String hello(){
return "hello";
}
}
启动并访问http://localhost:8080/hello
3 配置pom文件
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-jav