一、创建工程
创建名称为”HelloWorld_SpringBoot”的spring boot工程, new->Spring Starter Project
勾选需要的业务:
二、开始编码
创建HelloController
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程序就写好啦~~~是不是很方便呢?
打赏
微信扫一扫~听说打赏我的人,都进了福布斯排行榜!
You got a very excellent website, Gladiola I found it through yahoo.