1、利用idea工具构建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 https://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.6.3</version> <relativePath/> <!-- lookup parent from repository --> </parent> <!--当前项目信息--> <groupId>wyq.test</groupId> <artifactId>springboot</artifactId> <version>1.0.0</version> <name>springboot</name> <description>test springboot 2.6.3 new characteristic</description> <properties> <java.version>1.8</java.version> </properties> <!--仅引用了starter和test组件--> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <!--采用maven构建--> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
主要有以上四部分:父项目版本、当前项目信息、启用的组件,构建编译的方式
问题1:父项目都起了什么作用?
进入spring-boot-starter-parent父项目依赖可以看到父项目如下内容:
作用:1、加载了spring-boot-dependences版本依赖的加载;
2、设置了版本默认的jdk、编译目录、默认字符集、资源定界符
问题2:父项目加载了哪些依赖?
进入spring-boot-dependencies的pom文件,可以看到如下内容,
官网也有详细的清单:Dependency Versions
当我们引用了默认的依赖时,因此可以不用写版本号,父依赖项目中已标注好了版本号