一、创建工程
创建名称为”HelloWorld_SpringBoot”的spring boot工程, new->Spring Starter Project
勾选需要的业务:
二、开始编码
创建HelloController
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
package
com.BubblyYi.cotroller;
import
org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping (value= "/index" )
public
class
HelloController {
@RequestMapping (value= "/hello" )
public
String sayHello(){
return
"hello world!" ;
}
}
|
启动项目

你的控制台会输入这样的信息
当出现 Started HelloWorldSpringBootApplication 字样时表示项目启动成功!
我们在浏览器中敲入http://localhost:8080/index/hello 就会出现以下信息。
至此呢,第一个HelloWorld web程序就写好啦~~~是不是很方便呢?