Spring Boot 开发入门
一、简单网站 HelloSpringBoot搭建
1.创建hellospringboot工程文件
1) 选择Spring Initializr
2) 填写Group和Artifact,并选择Java version为8
3) 选择Web–>spring we
4) 为项目创建名称和项目保存位置
- 如下为创建完成后的项目文件结构
首次使用springboot创建配置文件时可能会加载较长时间,耐心等待即可
2.编写Demo Application代码
代码如下:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
public class DemoApplication {
@RequestMapping(value = "/hello",method = RequestMethod.GET)
public String hello(){
return "helloword Spring Boot!这是一个用Spring Boot开发的网站。";
}
pu