1、打开IDEA,新建项目,选择Spring Initializr,点击next
2、填写相关信息,点击next
3、可以选择Spring Web,也可以不选,咱们这里先不选,点击next
4、检查项目名称和项目地址有没有写对,点击finish
5、项目新建完成
6、删去以下多余的文件
7、运行Springboot01StudyApplication,结果如下:运行完就停止了
8、接下来我们导入web依赖,在pom.xml文件中导入web依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
9、再次运行Springboot01StudyApplication,结果如下:会看到它把Tomcat集成进来了
10、编写一个如下一个HelloController
11、重新运行Springboot01StudyApplication,打开浏览器,输入网址localhost:8080/hello/hello,回车,浏览器显示如下