从入门到入门-Spring Boot-第一个Spring Boot应用

来源:互联网 发布:亚马逊订单管理 软件 编辑:程序博客网 时间:2024/06/02 01:44

一.开始前准备

     Maven 3.5.0

     Jdk 1.8.0_131

     IntelliJ IDEA 2.17.1.3


二. IntelliJ IDEA 对JDK的配置


三.IntelliJ IDEA对 Tomcat的配置


四.IntelliJ IDEA对 Maven的配置


五.开发一个 Hello Spring Boot项目

1.创建一个Project ,如图,默认URL为 https://start.spring.io,之后点击Next


2.填入相关信息,如图,之后点击Next


3.选择Web-Web 如图,点击Next


4.直接点击Next


5.最终的项目结构图


6.之后会有很长一段时间的Maven下载Jar包的过程,大约5分钟后,运行程序


7.运行之后,控制台打印结果如图,我们可以看到Tomcat已经启动,端口为8080


8.访问http://localhost:8080


这个页面证明SpringBoot已经启动,但是没有找到对应的文件。

10.创建一个UserController类

package com.demo;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestMethod;import org.springframework.web.bind.annotation.RestController;/** * Created by chenjianfei on 2017-7-11. */@RestControllerpublic class UserController {    @RequestMapping(value="/hello",method = RequestMethod.GET)    public String say(){        return "hello Spring Boot!!";    }}


11.重启SpringBoot应用,访问http://localhost:8080/hello



到目前为止,第一个hello Spring Boot 测试成功!!!!!!!