项目目录结构如下:
spring-boot入门例子

1、选择Eclipse菜单Help–>Eclipse Marplace–>search,搜到STS并安装,安装完成后重启eclipse
spring-boot入门例子
2、新建项目New–>Other–>Spring Boot—>spring starter project,其余的可以选择默认的就行了。最后点击Finish按钮。
spring-boot入门例子

3、新建SampleController.java文件

package com.example.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SampleController {

	@RequestMapping("/hello")
    String home() {
        return "Hello World!";
    }
}

4、数遍点击项目,右键选择Run As–>Spring Boot App,程序启动后,在浏览器中打开网页http://localhost:8080/hello,
结果如下:
spring-boot入门例子

相关文章: