一、创建工程

创建名称为”HelloWorld_SpringBoot”的spring boot工程, new->Spring Starter Project

SpringBoot9
SpringBoot10
勾选需要的业务:
SpringBoot11

二、开始编码

创建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!";  
    }  
}

启动项目

SpringBoot14

你的控制台会输入这样的信息

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

欢迎转载,转载时请标明出。

查看更多文章请访问我的个人博客 www.bubblyyi.com

请喝咖啡☕️

打赏

One Comment

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注