随笔 - 191  文章 - 0  评论 - 0  阅读 - 45568

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

posted on   风中明月  阅读(642)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示