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!
本文介绍如何使用STS或Eclipse安装STS插件进行Spring Boot 2.x项目的开发,从构建项目到运行Chapter2Application类,再到创建HelloController类进行测试。通过Postman测试工具验证项目成功运行。
1655

被折叠的 条评论
为什么被折叠?



