Spring的配置繁琐,所以出现了SpringBoot,其目的是简化Spring的配置及开发。
创建SpringBoot项目选择Spring Initializr
这里jdk我选择8
添加依赖添加maven依赖
编写HelloControllerorg.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test
新建controller包,HelloController.java
package com.example.demo.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 "HelloSpringBoot!";
}
}
运行项目
运行代码,输入网址http://localhost:8080/hello
一个SpringBoot就完成了,不需要配置任何文件。



