我的第一个SpringBoot项目

一.新建一个Spring Starter Project,项目结构如下:
在这里插入图片描述

二.测试程序:
HelloSpringBootApplication是SpringBoot的启动类,我们先对其直接右键:
Run As->Spring Boot App。然后打开网页:localhost:8080 就可以看到:
在这里插入图片描述
说明项目暂时没有什么问题了,接下来写个测试程序吧。

三. HelloWorld
在package下创建HelloWorld类,简单写入:

package com.example;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWorld {

	@RequestMapping("/helloworld")
	public String Say() {
		return "欢迎来到Sringboot的世界!";
	}
}

打开浏览器输入:localhost:8080/helloworld 就可以看到:
在这里插入图片描述
至此,大功告成了!

猜你喜欢

转载自blog.csdn.net/weixin_43324905/article/details/83187210