springboot中的pom文件是如何管理依赖的
我们来看一下新建完成后的springboot中的pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.guomie</groupId>
<artifactId>spring-boot-ymal</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-ymal</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<!--web依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>
我们主要看一下他的父依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<!--父类的父类 -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath>../../spring-boot-dependencies</relativePath>
</parent>
这里我们可以看到他里面有些写版本的依赖和版本号
依赖配置都声明在了dependencyManagement 里面,所以他的子项目不会自动注入这些依赖,只能通过自项目显示注入自己需要的依赖,默认用的就是父依赖中的版本号,所以我们在注入这种starter的时候不需要指定版本号。
我们再看一下我们引入的starter
这里我们以web为例 这里显示依赖了web启动器,他的版本默认就是父类中的版本号
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
点进去看到他还会有一些其他的依赖
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>2.1.6.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
<version>2.1.6.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>2.1.6.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.17.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.8.RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.1.8.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>
所以springboot帮我们管理好了所需要依赖的版本号,而且按照模块去封装成一个个starter,我们在使用的时候就很更简单快捷。
springboot中的pom文件是如何管理依赖的的更多相关文章
- SpringBoot-02:SpringBoot中的POM文件详细解释
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 我把pom文件,以及它的详细解释发出来 <?xml version="1.0" en ...
- springboot 框架 - 探究-pom文件
一.pom文件 父项目 <parent> <groupId>org.springframework.boot</groupId> <artifactId> ...
- springboot配置文件读取pom文件信息
解决的问题 springboot(当然别的也可以)多环境切换需要该配置文件,打包时不够方便. 解决: 配置文件能读取pom文件中的配置,根据命令选择不同配置注入springboot的配置文件中 pom ...
- idea中的pom文件中的jar包下载不了,手动下载jar包的方法
问题描述: 在pom文件中添加依赖的时候,程序怎么着都是下载不了,而且实验了各种方式: IDEA引MAVEN项目jar包依赖导入问题解决 https://www.cnblogs.com/a845701 ...
- springboot中对yaml文件的解析
一.YAML是“YAML不是一种标记语言”的外语缩写 (见前方参考资料原文内容):但为了强调这种语言以数据做为中心,而不是以置标语言为重点,而用返璞词重新命名.它是一种直观的能够被电脑识别的数据序列化 ...
- springboot中访问jsp文件方式
首先,添加加载jsp文件的依赖包: <!--jsp依赖 对应springboot版本为2.1.4--><dependency> <groupId>org.apach ...
- 什么是maven?maven中的pom文件是做什么的?
Maven 是专门用于构建和管理Java相关项目的管理工具. 1.使用Maven管理的Java 项目都有着相同的项目结构 2.统一维护jar包 POM是项目对象模型(Project Object Mo ...
- Springboot整合SpringSecurity--对静态文件进行权限管理
文章目录 一.要求 二.依赖管理 三.配置config文件 四.扩展 一.要求 index.html 可以被所有用户访问 1.html只能被VIP1访问 2.html只能被VIP2访问 3.html只 ...
- SpringBoot中自定义properties文件配置参数并带有输入提示
1. 创建配置类 在项目中创建一个参数映射类如下 @ConfigurationProperties(prefix = "user.info") public class MyPro ...
随机推荐
- SpringBoot 整合NoSql
通用配置 maven依赖 添加Spring-Web和Spring-Security依赖,使用Spring-Security是因为使用SpringBoot的Redis依赖时,必须添加Spring-Sec ...
- logback日志回顾整理--2018年8月8日
几年前使用过logback作为项目的日志框架. 当时觉得这个框架比log4j更加好用. 所以系统的学习了一遍. 后来换了公司, 不再使用logback. 如今, 又有机会使用logback了, 所以, ...
- nyoj 42-一笔画问题 (欧拉图 && 并查集)
42-一笔画问题 内存限制:64MB 时间限制:3000ms Special Judge: No accepted:10 submit:25 题目描述: zyc从小就比较喜欢玩一些小游戏,其中就包括画 ...
- oracle 数据库,能不能将查询的结果创建成新表。
这个是可以的.sql:create table tablename1 as select t2. * from tablename2 t2 where t2.filename =‘张三’. 解释:就是 ...
- Linux内核版本 uname命令 GNU项目 Linux发行版
1.内核版本由linux内核社区统一编码和发布,格式如下图: major.minor.patch-build.desc 主版本号.次版本号.对次版本号的修订次数-编译次数.当前版本的特殊信息 次版本号 ...
- 图解Elasticsearch的核心概念
本文讲解大纲,分8个核心概念讲解说明: NRT Cluster Node Document&Field Index Type Shard Replica Near Realtime(NRT)近 ...
- libwebsocket协议切换状态机
libwebsocket为连接(connection)定义了一组状态机-lws_connection_states,通过状态机我们来看libwebsocket如何实现协议的切换.除了lws_conne ...
- pod删除主要流程源码解析
本文以v1.12版本进行分析 当一个pod删除时,client端向apiserver发送请求,apiserver将pod的deletionTimestamp打上时间.kubelet watch到该事件 ...
- python基础-面向对象编程之继承
面向对象编程之继承 继承的定义:是一种新建类的方式,新建的类称之为子类或派生类,被继承的父类称之为基类或超类 继承的作用:子类会""遗传"父类的属性,从而解决代码重用问题 ...
- 20191031-9 beta week 1/2 Scrum立会报告+燃尽图 07
此作业要求参见https://edu.cnblogs.com/campus/nenu/2019fall/homework/9917 一.小组情况 队名:扛把子 组长:孙晓宇 组员:宋晓丽 梁梦瑶 韩昊 ...