Eclipse spring boot 环境搭建
1、安装sts工具
Help -> Eclipse Marketplace…
Search或选择"Popular"标签,选择Spring Tool Suite (STS) for Eclipse插件,安装
注意这个安装时间比较长哦!要耐心!
2、new project ,选择spring -> spring starter project
3 项目依赖选择:
4 目录结构:
5 :/src/main/resource/application.properties 改成application.yml 添加 port
server:
port: 8081
主类 里添加hello (也可以写@Controller
,写自己的页面):
@RestController
@SpringBootApplication
public class MyspringBootApplication {
@RequestMapping("/hello")
public String hello() {
return "hello nihao";
}
public static void main(String[] args) {
SpringApplication.run(MyspringBootApplication.class, args);
}
}
6运行;
MyspringBootApplication
点击run:
直接访问:localhost:8081/hello