springboot工程搭建(入门案例)

第一步:创建maven工程

第二步:设置项目信息

第三步:默认项目名称,不用改动(第二步已填写)

 第三步:在pom.xml中导入依赖

SpringBoot要求,项目要继承SpringBoot的起步依赖spring-boot-starter-parent

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

SpringBoot要集成SpringMVC进行Controller的开发,所以项目要导入web的启动依赖

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

第四步:编写SpringBoot引导类

 import org.springframework.boot.SpringApplication;
importorg.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication
public class MySpringBootApplication { public static void main(String[] args) {
SpringApplication.run(MySpringBootApplication.class);
} }

第五步:编写Controller

 1 import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody; @Controller
public class StartController { @RequestMapping("/hello")
@ResponseBody
public String init(){
return "hi,springboot!";
} }

 第六步:启动MySpringBootApplication.java的主方法(即启动项目)

项目启动完成........开心

测试结果如下:

完成项目搭建!!!!

最新文章

  1. Nagios NSclient Failed to get CPU value: \238(_total)\6: Failed to get mutex :(
  2. Cygwin: connection closed by ::1
  3. [iOS] UIImage和CGImageRef
  4. android webview type=file文件上传,安卓端代码
  5. 基于jQuery编写的横向自适应幻灯片切换特效
  6. Linux FTP的安装与配置(转)
  7. 照猫画虎学gnuplot之简单介绍
  8. 转: linux文件链接(软链接和硬链接)
  9. Web.Config Transformation配置灵活的配置文件
  10. wstring操作与普通段字符操作对照表
  11. 【刷题】Git工作流-相关知识点
  12. PDF转换成Word,ppt转换成word
  13. ----Juquery复选框全选反选及获取选中值Value
  14. 前端学习历程--localstroge
  15. Python机器学习/LinearRegression(线性回归模型)(附源码)
  16. python try详细说明(python的异常捕捉模块)
  17. 面对对象程序设计_task2_C++视频教程
  18. org.apache.ibatis.builder.IncompleteElementException: Could not find parameter map com.hyzn.historicalRecord.dao.ITB_HISTORYLOGDAO.TB_HISTORYLOGResultMap
  19. Java 如何获取系统时间
  20. Failed to resolve: com.android.support:appcompat-v7:27.+ 报错解决方法

热门文章

  1. 微信小程序开发之三元运算符代替wx.if/wx.else
  2. java.endorsed.dirs
  3. 【原创】Gitbook使用
  4. HihoCoder 1121二分图一•二分图判定
  5. C++中的声明与定义
  6. sql数据库查询结果字段包含换行符导致复制到Excel发生错位问题的解决
  7. 关于 js中的arguments 对象
  8. lucene原理及java实现
  9. Codeforces Round #533(Div. 2) D.Kilani and the Game
  10. [WOJ3010] 骰子