Java-Springboot介绍
一.Springboot入门案例
步骤:
①:创建新模块,选择Spring Initializr,并配置模块相关基础信息(必须在联网条件下创建)
可以采用spring官方的网址 https://start.spring.io/,也可以用阿里的网址 https://start.aliyun.com
②:选择当前模块需要使用的技术集
做什么项目勾选什么模块。。。
③:开发控制器类
1 |
|
④:运行自动生成的Application类
1 |
|
二.pom坐标介绍
- parent
- starter
- 引导类
- 内嵌tomcat
1.parent:
- 所有SpringBoot项目要继承的项目,定义了若干个坐标版本号(依赖管理,而非依赖),以达到减少依赖冲突的目的(
坐标) - spring-boot-starter-parent各版本间存在着诸多坐标版本不同
1 | <parent> |
2.starter:
SpringBoot中常见项目名称,定义了当前项目使用的所有依赖坐标,以达到减少依赖配置的目的
实际开发:
使用任意坐标时,仅书写GAV中的G和A,V由SpringBoot提供,除非SpringBoot未提供对应版本V
如发生坐标错误,再指定Version(要小心版本冲突)
3.引导类:
启动方式:运行Application类。
SpringBoot的引导类是Boot工程的执行入口,运行main方法就可以启动项目
SpringBoot工程运行后初始化Spring容器,扫描引导类所在包加载bean
4.内嵌tomcat:
spring-boot-starter-web坐标中导入了spring-boot-starter-tomcat坐标,spring-boot-starter-tomcat坐标中又导入了tomcat核心加载文件tomcat-embed-core坐标。
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment
ValineDisqus