IDEA+Maven 构建spring boot demo
一、通过Spring Initializr工具产生基础项目
b:选择构建工具Maven Project、Spring Boot版本,一些基本信息:
c:点击Generate Project
d:解压得到的压缩包
二、Idea导入Maven项目
- 菜单->File->New->Project from Existing Sources...
- 选择解压文件夹导入
- Import project from external model 并选择 Maven,一路next
-
现存pom.xml中有两个模块:
- spring-boot-starter:核心模块,包括自动配置支持,日志等
- spring-boot-starter-test:测试模块,包括JUnit等
-
现存pom.xml中有两个模块:
- 引入web模块
四、编写helloworld
a:在主程序包下创建子包com.springBoot.web
b:在该子包内创建类HelloController:
c:启动主程序,此时可以看见Tomcat顺利启动
d:在浏览器地址栏输入:http://loccalhost:8080/hello,页面显示:Hello World!