URL:https://start.spring.oi 可以换成 https://start.aliyun.com

选择所需要的依赖:如添加springmvc依赖

创建后的目录如下:

有的目录不需要,可以将其删除,删除后的目录如下:

xxxxApplication:里面的 @SpringBootApplication注解,顶替了SSM中的各种配置文件
static:存放静态资源,如css、js等
templates:存放模板
application.propertes:springboot的配置文件
1. 编写Controller
- package com.xdu.studyspringboot.controller;
-
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
-
- @Controller
- public class Hello {
- @RequestMapping("/hello")
- @ResponseBody
- public String helloSpringBoot(){
- return "SpringBoot框架";
- }
- }
2. 访问http://localhost:8080/hello,可以看到网站上输出了:SpringBoot框架
可以在配置文件application.propertes中添加相关内容,用来修改默认启动配置,如:
- #设置端口号
- server.port=8080
- #设置访问应用的上下文路径
- server.servlet.context-path=/study