使用spring initializr ( 4.快速创建springboot工程 )(入门结束)



组织id com.tabctrlshift
模块id spring-boot-01-helloworld-quick

可以看看下面的东西


最终只选择web
选择我们需要的模块即可

wokao,就这样联网自动生成了!

用不上的删掉

选择弹出的自动导入。
万一没有选中这里有个刷新图标手动刷新导入

新建一个HelloController类

package com.tabctrlshift.springboot.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
////这个类的所有方法返回数据直接写给浏览器,如果是对象转为json数据
//@ResponseBody
//@Controller
//以上两者的合并写法
@RestController
public class HelloController {
// 要写给浏览器
// @ResponseBody
// 处理hello请求
@RequestMapping("/hello")
public String Hello(){
return "hello";
}
}

ok。
主程序已经写好了,只需要写业务逻辑 。

如果用sts就是生成spring starter project


浙公网安备 33010602011771号