搭建一个入门springboot工程
2024-08-30 12:03:49
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的主方法(即启动项目)
项目启动完成........开心
测试结果如下:
完成项目搭建!!!!
最新文章
- Nagios NSclient Failed to get CPU value: \238(_total)\6: Failed to get mutex :(
- Cygwin: connection closed by ::1
- [iOS] UIImage和CGImageRef
- android webview type=file文件上传,安卓端代码
- 基于jQuery编写的横向自适应幻灯片切换特效
- Linux FTP的安装与配置(转)
- 照猫画虎学gnuplot之简单介绍
- 转: linux文件链接(软链接和硬链接)
- Web.Config Transformation配置灵活的配置文件
- wstring操作与普通段字符操作对照表
- 【刷题】Git工作流-相关知识点
- PDF转换成Word,ppt转换成word
- ----Juquery复选框全选反选及获取选中值Value
- 前端学习历程--localstroge
- Python机器学习/LinearRegression(线性回归模型)(附源码)
- python try详细说明(python的异常捕捉模块)
- 面对对象程序设计_task2_C++视频教程
- org.apache.ibatis.builder.IncompleteElementException: Could not find parameter map com.hyzn.historicalRecord.dao.ITB_HISTORYLOGDAO.TB_HISTORYLOGResultMap
- Java 如何获取系统时间
- Failed to resolve: com.android.support:appcompat-v7:27.+ 报错解决方法
热门文章
- 微信小程序开发之三元运算符代替wx.if/wx.else
- java.endorsed.dirs
- 【原创】Gitbook使用
- HihoCoder 1121二分图一•二分图判定
- C++中的声明与定义
- sql数据库查询结果字段包含换行符导致复制到Excel发生错位问题的解决
- 关于 js中的arguments 对象
- lucene原理及java实现
- Codeforces Round #533(Div. 2) D.Kilani and the Game
- [WOJ3010] 骰子