IDEA+Maven 构建spring boot demo

一、通过Spring Initializr工具产生基础项目

    a:访问 http://start.spring.io/

    b:选择构建工具Maven Project、Spring Boot版本,一些基本信息:

IDEA+Maven 构建spring boot demo

    c:点击Generate Project

    d:解压得到的压缩包 

二、Idea导入Maven项目

      1. 菜单->File->New->Project from Existing Sources...
      2. 选择解压文件夹导入
      3. Import project from external model 并选择 Maven,一路next
三、引入Web模块
      1. 现存pom.xml中有两个模块:
        1. spring-boot-starter:核心模块,包括自动配置支持,日志等
        2. spring-boot-starter-test:测试模块,包括JUnit等
IDEA+Maven 构建spring boot demo
  1. 引入web模块
IDEA+Maven 构建spring boot demo
四、编写helloworld

    a:在主程序包下创建
子包com.springBoot.web
    b:在该子包内创建类HelloController:

IDEA+Maven 构建spring boot demo
    c:启动主程序,此时可以看见Tomcat顺利启动

    d:在浏览器地址栏输入:http://loccalhost:8080/hello,页面显示:Hello World!