SpringBoot系列(三)——Springboot项目中的spring-boot-starter-parent,spring-boot-dependencies依赖关系

目录

1、项目pom文件依赖,父级项目spring-boot-starter-parent

2、再看spring-boot-starter-parent

3、spring-boot-dependencies-2.2.2.RELEASE.pom

4、总结


使用简单的Springboot生成项目很简单,简单归简单,那他究竟默认都帮我们引入了哪些包。pom文件的依赖关系又是怎样的。

让我们一探究竟。

 

1、项目pom文件依赖,父级项目spring-boot-starter-parent

以一个简单的springboot工程来查看其pom文件,可以看出父级项目是spring-boot-starter-parent



    4.0.0

    
    
        org.springframework.boot
        spring-boot-starter-parent
        2.2.2.RELEASE
        
    
    com.example
    demo
    0.0.1-SNAPSHOT
    demo
    Demo project for Spring Boot

    
        1.8
    

    
        
            org.springframework.boot
            spring-boot-starter
        

        
            org.springframework.boot
            spring-boot-starter-test
            test
            
                
                    org.junit.vintage
                    junit-vintage-engine
                
            
        
    

    
        
            
                org.springframework.boot
                spring-boot-maven-plugin
            
        
    


 

2、再看spring-boot-starter-parent


点击进spring-boot-starter-parent再看其pom文件,spring-boot-starter-parent-2.2.2.RELEASE.pom ,注释说明了该文件的一些注意点。


  4.0.0
  
    org.springframework.boot
    spring-boot-dependencies
    2.2.2.RELEASE
    
    ../../spring-boot-dependencies
  
  spring-boot-starter-parent
  pom
  Spring Boot Starter Parent
  Parent pom providing dependency and plugin management for applications
        built with Maven
  https://projects.spring.io/spring-boot/#/spring-boot-starter-parent

  
    UTF-8
    1.8

    
    @
    ${java.version}
    UTF-8
    ${java.version}
  

  
  
    
      
        true
        ${basedir}/src/main/resources
        
          **/application*.yml
          **/application*.yaml
          **/application*.properties
        
      
      
        ${basedir}/src/main/resources
        
          **/application*.yml
          **/application*.yaml
          **/application*.properties
        
      
    

    
      
        
          org.jetbrains.kotlin
          kotlin-maven-plugin
          ${kotlin.version}
        
    
      
    
  

3、spring-boot-dependencies-2.2.2.RELEASE.pom

根据spring-boot-starter-parent-2.2.2.RELEASE.pom 的父级项目spring-boot-dependencies再继续分析,下面的文件省去原有大量的properties和dependency


  4.0.0
  org.springframework.boot
  spring-boot-dependencies
  2.2.2.RELEASE
  pom
  Spring Boot Dependencies
  Spring Boot Dependencies
  https://projects.spring.io/spring-boot/#
  
    
      Apache License, Version 2.0
      https://www.apache.org/licenses/LICENSE-2.0
    
  
  
    
      Pivotal
      [email protected]
      Pivotal Software, Inc.
      https://www.spring.io
    
  
  
    https://github.com/spring-projects/spring-boot
  

   
  
    5.15.11
     
  


  
  
    
      
        org.springframework.boot
        spring-boot
        2.2.2.RELEASE
      
    
  

  
    
    
      
        
          org.apache.johnzon
          johnzon-maven-plugin
          ${johnzon.version}
        
      
    
  

4、总结

总结一下,继承 spring-boot-starter-parent 来作为父项目, spring-boot-starter-parent的父项目又是Spring Boot Dependencies,
已经定义好了很多包的依赖,可以统一项目的依赖,避免后续的版本冲突。

Maven users can inherit from the spring-boot-starter-parent project to obtain sensible defaults. The parent project provides the following features:

Java 1.8 as the default compiler level.
UTF-8 source encoding.
A Dependency Management section, inherited from the spring-boot-dependencies pom, that manages the versions of common dependencies. This dependency management lets you omit tags for those dependencies when used in your own pom.
An execution of the repackage goal with a repackage execution id.
Sensible resource filtering.
Sensible plugin configuration (exec plugin, Git commit ID, and shade).
Sensible resource filtering for application.properties and application.yml including profile-specific files (for example, application-dev.properties and application-dev.yml)
Note that, since the application.properties and application.yml files accept Spring style placeholders (${…​}), the Maven filtering is changed to use @..@ placeholders. (You can override that by setting a Maven property called resource.delimiter.)


Java
默认使用Java 8
使用UTF-8编码
一个引用管理的功能,在dependencies里的部分配置可以不用填写version信息,这些version信息会从spring-boot-dependencies里得到继承。
识别资源过滤
识别插件的配置(exec plugin, surefire, Git commit ID, shade).能够识别application.properties和application.yml类型的文件,同时也能支持profile-specific类型的文件(如: application-foo.properties and application-foo.yml,这个功能可以更好的配置不同生产环境下的配置文件)。
 
摘自官方文档https://docs.spring.io/spring-boot/docs/1.3.0.M5/reference/html/using-boot-build-systems.html

你可能感兴趣的:(Spring家族系列,springboot依赖,starter,dependencies,filtering,maven)