Springboot中的依赖管理
1.1依赖管理
在pom.xml中
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
</parent>
他的父项目为:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.3.4.RELEASE</version>
</parent>
ctrl+鼠标左键点击 <artifactId>spring-boot-starter-parent</artifactId>即可进入
在父项目spring-boot-dependencies中几乎声明了所有开发中常用的依赖的版本号
-----------------------------------------------------------------------------------------------------------------------
如何添加依赖:
比如添加使用mysql的依赖,在父项目spring-boot-dependencies-2.3.4.RELEASE.pom中搜索到mysql的依赖后,在pom.xml中添加即可。
1.查看spring-boot-dependencies中是否有对应依赖,
2.添加至pom.xml文件中:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
--------------------------------------------------------------------------------------------------------------------------
如何修改依赖的版本号:
1.查看spring-boot-denpendencies中规定当前依赖的版本使用的key
2.在项目的pom.xml中重写配置
如:mysql的版本号
<properties>
<mysql.version>5.1.43</mysql.version>
</properties>
--------------------------------------------------------------------------------------------------------------------------
开发导入starter场景启动器
1.在springboot项目的pom.xml文件中可以引入starter
spring-boot-starter-*
2.只要引入starter,这个场景的所有常规需要的依赖都会被自动引入,如:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
引入web场景
3.SpringBoot所有支持的场景见SpringBoot开发文档
https://docs.spring.io/spring-boot/docs/current/reference/html/using.html#using.build-systems.starters
4.也可以使用第三方提供的简化开发的场景启动器
*-spring-boot-starter
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!