SpringBoot图文教程1「概念+案例 思维导图」「基础篇上」(12)

demo需求

  • 使用SpringBoot搭建 web 环境

  • 创建UserController类 , 类中定义 getUser() 方法 该方法会以Json的方法返回一句话:SpringBoot 真香 。

  • 运行项目能够请求到该方法 并得到响应数据

Tips:案例代码 见 GitHub 和 码云仓库

1.用IDEA创建一个空的maven项目 完善项目结构

2.在 pom.xml 中写入 SpringBoot 的依赖

<?xml version=\"1.0\" encoding=\"UTF-8\"?><project xmlns=\"http://maven.apache.org/POM/4.0.0\"         xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"         xsi:schemaLocation=\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\">    <modelVersion>4.0.0</modelVersion><groupId>com.lu</groupId><artifactId>boot-hello</artifactId><version>1.0-SNAPSHOT</version><!--继承springboot的父项目--><parent>    <groupId>org.springframework.boot</groupId>    <artifactId>spring-boot-starter-parent</artifactId>    <version>2.0.3.RELEASE</version></parent><dependencies>    <!--引入springboot的web支持-->    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-web</artifactId>    </dependency></dependencies>复制代码</project>复制代码复制代码

推荐阅读