Spring boot 快速入门

337 阅读1分钟

 1.创建Maven工程

1.1使用idea工具创建Maven工程

1.2设置项目的名字和存放位置

2.在pom.xml中添加spring boot 依赖

2.1添加起步依赖spring-boot-starter-parent

<parent>   
 <groupId>org.springframework.boot</groupId> 
 <artifactId>spring-boot-starter-parent</artifactId>   
 <version>2.0.1.RELEASE</version>
</parent>

2.2添加web起步依赖

<dependencies>  
  <!--  web功能的起步-->  
  <dependency>        
     <groupId>org.springframework.boot</groupId>   
     <artifactId>spring-boot-starter-web</artifactId>  
  </dependency>
</dependencies>

3.创建入口文件

3.1创建入口文件AppRun

注意在这前需要先跑一下Maven,确保依赖已经注入

3.2运行看到如下表示环境成功

访问http://localhost:8080/

4.创建controller看效果

创建一个demo

运行http://localhost:8080/demo  在浏览器看到

环境搭建成功