第一章-spring boot快速入门hello world

1、spring boot 简介

  每个spring boot 项目都是以spring的子项目的形式来运行,开发人员不用再去关注繁琐的配置文件,能够把精力放到业务逻辑以及更深层次的架构方面。git

2、环境

  1. jdk1.8
  2. springboot 1.5.9.RELEASE
  3. apache maven(3.5.0)
  4. 开发工具(IntelliJ IDEA )

3、步骤

  1) 打开idea 选择file new projecgithub

  

  2)找到Spring Initializr选中点击next。web

  

  3)点击nextspring

  

  4)入门项目只勾选web就能够,这里的标红版本为几个推荐版本会变化,后期咱们本身在pom.xml中调整便可,点击next选择项目目录便可。chrome

  

  5)找到pom文件并修改版本apache

修改前
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.13.BUILD-SNAPSHOT</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

修改后

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.9.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

  6)项目结构简介浏览器

  

  7)编写hello world并运行,@RestController能够直接响应给前段,传统写法@Controller+@ResponseBodyspringboot

  

  右击运行并访问,默认端口8080,chrome浏览器访问。架构

  

   

  8)打包运行,由于咱们选择的是jar方式打包因此经过mvn clean package就能够打成jat包运行。maven

  

  也可maven projects打包更方便,根据须要可自行开启配置,找到target目录打开cmd命令行运行。

           

4、总结

   一个简单的spring boot hello world 程序就写好了。

  源码地址    https://github.com/binary-vi/binary.github.io/tree/master/SpringBoot-demo/demo01 

相关文章
相关标签/搜索