spring boot 入门01
1、新建spring boot web项目
背景:
-
在以往的web项目中,我们需要spring mvc 、 spring 、 mybatis 三大框架进行大量的配置操作
-
在spring boot中就剩出了繁琐的配置操作,在启动项目中我们采用了一键式启搭建项目,在spring boot中强调”约定大于配置“;
2、idea 创建 spring boot 工程
第一步、点击file新建project 选择 Spring Initializr 如下图:
第二步、自定义项目的元数据 ,然后点击next
第三步、选择web项目、勾选spring web 点击 next
第四步、选择项目放置的目录空间,点击finish
第五步、新建java bean HelloWorld如下:
package com.example.demo; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; /** * Description: * User: oycc * Date: 2019-12-09 */ @RestController public class HelloWorld { @RequestMapping("hello") public String HelloWorld(){ return "hello world spring boot"; } }
第六步、启动项目
第七步、访问接口:
在浏览器中输入http://localhost:8080/hello
成功!!!!!!!!