springboot快速入门
SpringBoot入门 快速
2023-06-13 09:13:24 时间
springboot快速入门
快速入门两种方式
1.访问官网https://start.spring.io/构建 2.使用maven构建
开发环境
- jdk:jdk1.8.0_212
- maven:apache-maven-3.6.2
- springboot版本:2.2.0
https://start.spring.io/构建
1.访问https://start.spring.io/,选择springboot版本2.2.0,java版本8
2.点击Generate-Ctrl即可下载初始化项目到本地
3.解压项目,然后idea打开项目的根目录
4.可以看到pom.xml文件中自动引入了这些依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<!--核心模块,包括自动配置支持、日志和YAML-->
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<!--测试模块,包括JUnit、Hamcrest、Mockito-->
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
引入Web模块,方便后面测试
<dependency>
<groupId>org.springframework.boot</groupId>
<!--web模块-->
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
创建controller类com.zjq.demo.controller.TestController,内容如下
@RestController
public class TestController {
@RequestMapping(value = "/hello")
public String hello(){
return "HelloWorld";
}
}
启动主程序,访问 http://localhost:8080/hello ,可以看到页面输出 HelloWorld
使用maven构建
1.使用idea,点击File,new >>project,老版idea可以直接用 SPRING INITIALIZR 新建项目,新版的idea需要添加
Spring Assistant插件,添加好后重启idea,点击File,new >>project,选择Spring Assistant,选择SDK版本,使用default https://start.spring.io/ 构建项目
4.可以看到pom.xml文件中自动引入了这些依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
引入Web模块,方便后面测
创建controller类com.zjq.demo.controller.TestController,内容如下
@RestController
public class TestController {
@RequestMapping(value = "/hello")
public String hello(){
return "HelloWorldByIdea";
}
}
启动主程序,访问 http://localhost:8080/hello ,可以看到页面输出 HelloWorldByIdea
相关文章
- Spring学习笔记(十二)——SpringBoot基础和快速入门
- springboot到底是什么_Springboot启动流程
- Springboot源码_pe启动制作源码
- SpringBoot的启动流程_springboot启动卡住了
- 【SpringBoot 实战】数据报表统计并定时推送用户的手把手教程
- SpringBoot动态切换多数据源
- SpringBoot 面试题及答案
- [入门]SpringBoot-MyBatis-luckwheel-master开源代码审计
- SpringBoot 2.x 教你快速入门
- SpringBoot整合 mybatisPlus-入门篇
- SpringBoot项目整合Mybatis入门,看这一篇就够了
- SpringBoot | SpringBoot员工管理系统(超细笔记+静态资源链接+附完整源码)
- 用idea搭建springboot项目_springboot入门项目
- [Web开发]《SpringBoot + Email + Freemarker发送邮件》
- 如何运行SpringBoot项目
- MyBatis-Plus 入门 【SpringBoot版】
- idea创建springboot父子工程_Springboot框架
- springboot使用拦截器_通用mapper源码
- springboot测试中主程序中能加载bean测试中无法加载bean
- SpringBoot自动装配原理(简单易懂)
- MQ系列(3)——rabbitMQ结合springboot使用(1)
- SpringBoot漏洞,网站数据库要被删了。。
- 微信小程序+SpringBoot实现文件上传与下载
- SpringBoot(一)走进Springboot的世界详解编程语言
- springboot启动报:Error creating bean with name ‘dataSource’ defined in class path resource详解编程语言
- Springboot集成mybatis通用Mapper与分页插件PageHelper详解编程语言