美文网首页
springboot-02(springboot的pom文件解析

springboot-02(springboot的pom文件解析

作者: 誓俭草 | 来源:发表于2019-02-22 14:51 被阅读0次

    springboot的pom文件:

    1. 附上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>
    
       <groupId>com.ljj</groupId>
       <artifactId>Ljjboot-01</artifactId>
       <version>0.0.1-SNAPSHOT</version>
       <packaging>jar</packaging>
    
       <name>Ljjboot-01</name>
       <description>Demo project for Spring Boot</description>
    
       <parent>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-parent</artifactId>
           <version>2.1.0.RELEASE</version>
           <relativePath/> <!-- lookup parent from repository -->
       </parent>
    
       <properties>
           <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
           <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
           <java.version>1.8</java.version>
       </properties>
    
       <dependencies>
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter</artifactId>
           </dependency>
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-web</artifactId>
           </dependency>
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-starter-test</artifactId>
               <scope>test</scope>
           </dependency>
       </dependencies>
    
       <build>
           <plugins>
               <plugin>
                   <groupId>org.springframework.boot</groupId>
                   <artifactId>spring-boot-maven-plugin</artifactId>
               </plugin>
           </plugins>
       </build>
    </project>
    
    1. 可以看到他的父类项目为spring-boot-starter-parent
        <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>2.1.0.RELEASE</version>
            <relativePath/> <!-- lookup parent from repository -->
        </parent>
    

    我们点击进去可以看到:

    <parent>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>2.1.0.RELEASE</version>
            <relativePath>../../spring-boot-dependencies</relativePath>
        </parent>
        <artifactId>spring-boot-starter-parent</artifactId>
    

    spring-boot-starter-parent的父类为:spring-boot-dependencies
    点击进去:

    <properties>
         <activemq.version>5.15.7</activemq.version>
         <antlr2.version>2.7.7</antlr2.version>
         <appengine-sdk.version>1.9.67</appengine-sdk.version>
         <artemis.version>2.6.3</artemis.version>
         <aspectj.version>1.9.2</aspectj.version>
         <assertj.version>3.11.1</assertj.version>
         <atomikos.version>4.0.6</atomikos.version>
         <bitronix.version>2.1.4</bitronix.version>
         <build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
         <byte-buddy.version>1.9.3</byte-buddy.version>
         <caffeine.version>2.6.2</caffeine.version>
         <cassandra-driver.version>3.6.0</cassandra-driver.version>
         <classmate.version>1.4.0</classmate.version>
         <commons-codec.version>1.11</commons-codec.version>
         <commons-dbcp2.version>2.5.0</commons-dbcp2.version>
         <commons-lang3.version>3.8.1</commons-lang3.version>
         <commons-pool.version>1.6</commons-pool.version>
         <commons-pool2.version>2.6.0</commons-pool2.version>
         <couchbase-cache-client.version>2.1.0</couchbase-cache-client.version>
         <couchbase-client.version>2.7.0</couchbase-client.version>
         <derby.version>10.14.2.0</derby.version>
         <dom4j.version>1.6.1</dom4j.version>
         <dropwizard-metrics.version>4.0.3</dropwizard-metrics.version>
         <ehcache.version>2.10.6</ehcache.version>
         <ehcache3.version>3.6.1</ehcache3.version>
         <elasticsearch.version>6.4.2</elasticsearch.version>
         <embedded-mongo.version>2.1.1</embedded-mongo.version>
         <exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
         <flatten-maven-plugin.version>1.0.1</flatten-maven-plugin.version>
         <flyway.version>5.2.1</flyway.version>
         <freemarker.version>2.3.28</freemarker.version>
         <hamcrest.version>1.3</hamcrest.version>
         <hazelcast.version>3.11</hazelcast.version>
         <hazelcast-hibernate5.version>1.2.3</hazelcast-hibernate5.version>
         <hibernate.version>5.3.7.Final</hibernate.version>
         ....
         </properties>
    

    这个spring-boot-denpendencies来真正管理Spring Boot应用里面的所有依赖版本;
    所以我们可以知道:
    Spring Boot的版本仲裁中心;
    以后我们导入依赖默认是不需要写版本;(没有在dependencies里面管理的依赖自然需要声明版本号)

    springboot场景启动器

    1. 我们通过spring-boot-starts-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.0.RELEASE</version>
         <scope>compile</scope>
       </dependency>
       <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-json</artifactId>
         <version>2.1.0.RELEASE</version>
         <scope>compile</scope>
       </dependency>
       <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-tomcat</artifactId>
         <version>2.1.0.RELEASE</version>
         <scope>compile</scope>
       </dependency>
       <dependency>
         <groupId>org.hibernate.validator</groupId>
         <artifactId>hibernate-validator</artifactId>
         <version>6.0.13.Final</version>
         <scope>compile</scope>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-web</artifactId>
         <version>5.1.2.RELEASE</version>
         <scope>compile</scope>
       </dependency>
       <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-webmvc</artifactId>
         <version>5.1.2.RELEASE</version>
         <scope>compile</scope>
       </dependency>
     </dependencies>
    

    可以看出:spring-boot-starter-web:
    spring-boot-starter:spring-boot场景启动器;帮我们导入了web模块正常运行所依赖的组件;
    所以我们可以这么理解:
    Spring Boot将所有的功能场景都抽取出来,做成一个个的starters(启动器),只需要在项目里面引入这些starter 相关场景的所有依赖都会导入进来。要用什么功能就导入什么场景的启动器

    相关文章

      网友评论

          本文标题:springboot-02(springboot的pom文件解析

          本文链接:https://www.haomeiwen.com/subject/yydeyqtx.html