1.开发软件:STS(当然eclipse安装sts插件也是可以的)
2.构建项目:File–>New–>Spring Starter Project出现如下;
3.按照截图选择
4.项目结构如下
5.Chapter2Application类
package com.springboot.chapter2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Chapter2Application {
public static void main(String[] args) {
SpringApplication.run(Chapter2Application.class, args);
}
}
6.创建HelloController 类用于测试。
package com.springboot.chapter2.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class HelloController {
@RequestMapping(value = "/hello",method = RequestMethod.GET)
@ResponseBody
public String hello() {
return "Hello SpringBoot-2.x";
}
}
7.使用测试工具postman测试
测试OK!