需要软件
JDK 1.7+
Maven 3+
1.使用start.spring.io创建Spring Boot应用程序
引导Spring Boot应用程序的最佳方法是使用Spring Initializr。首先,我们先打开http//start.spring.io。我们可以使用Maven或Gradle来构建spring boot项目,我们使用Maven。
打开网址会看见
![](https://img.haomeiwen.com/i10503912/a85f5cdf3aa7c266.png)
步骤 :
选择 Maven Project
如果需要,可以更改group/Artifact名称
Packaging选Jar,Java版本选8(确保您的本地JDK 1.8或使用1.7)
我们还要增加Web,Actuator支持(图中红线部分)
点击Generate Project按钮下载zip文件
2.解压导入idea
![](https://img.haomeiwen.com/i10503912/baafc10050a16ff7.png)
3.创建HelloWorldController.class
package com.example.demo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloWorldController {
@GetMapping
public String helloWorld() {
return "hello word";
}
}
4.运行DemoApplication.class的main方法
![](https://img.haomeiwen.com/i10503912/479c642296cde938.png)
项目启动中。。。
![](https://img.haomeiwen.com/i10503912/2f314a74ae470123.png)
5.浏览器访问http://localhost:8080/
ok!!!
网友评论