国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

SpringBoot:模塊探究之spring-boot-dependencies

這篇具有很好參考價值的文章主要介紹了SpringBoot:模塊探究之spring-boot-dependencies。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

在 SpringBoot 開發(fā)時,我們常常會發(fā)現一個現象:即在 pom 文件中,加入一個新的依賴,往往不需要引入相應的版本號(如下代碼塊所示),就可以正常引入依賴,這其實是因為我們依賴了 spring-boot-starter-parent 模塊的緣故!

點 spring-boot-starter-parent 進去查看源文件會發(fā)現,spring-boot-starter-parent 繼承了 spring-boot-dependencies!

點 spring-boot-dependencies 進去查看源文件會發(fā)現,它在管理著相關依賴的版本。在 dependencyManagement 進行依賴管理,在 pluginManagement 中進行插件管理!

~

本篇內容包括:spring-boot-dependencies 模塊介紹、對 spring-boot-dependencies 依賴管理方法的借鑒



一、spring-boot-dependencies 模塊介紹

1、關于 spring-boot-starter-parent 模塊

在 SpringBoot 開發(fā)時,我們常常會發(fā)現一個現象:即在 pom 文件中,加入一個新的依賴,往往不需要引入相應的版本號(如下代碼塊所示),就可以正常引入依賴,這其實是因為我們依賴了 spring-boot-starter-parent 模塊的緣故!

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <!--   在這里指定了 spring boot 的版本     -->
    <version>2.7.2</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<dependencies>
    <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>
2、關于 spring-boot-dependencies 模塊

點 spring-boot-starter-parent 進去查看源文件會發(fā)現,spring-boot-starter-parent 繼承了 spring-boot-dependencies

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>2.7.2</version>
  </parent>

點 spring-boot-dependencies 進去查看源文件會發(fā)現,它在管理著相關依賴的版本。在 dependencyManagement 進行依賴管理,在 pluginManagement 中進行插件管理:

spring-boot-dependencies,Java框架,spring,spring boot,java


二、對 spring-boot-dependencies 依賴管理方法的借鑒

1、pom.xml 里的 dependencyManagement 節(jié)點

dependencyManagement 節(jié)點的作用是統一 maven 引入依賴 Jar 包的版本號,可以看出 spring-boot-dependencies 最重要的一個作用就是對 springboot 可能用到的依賴 Jar 包做了版本號的控制管理。

2、pom.xml 里的 pluginManagement 節(jié)點

pluginManagement 節(jié)點的作用是統一 Maven 引入插件的版本號,可以看出 spring-boot-dependencies 另一個作用是對 SpringBoot 可能用到的插件做了版本號的控制管理。

3、pom.xml 里的 plugins 節(jié)點

spring-boot-dependencies 引入(或覆蓋)了三個插件:

maven-help-plugin:用于獲取有關項目或系統的幫助信息;這個插件是 Maven 自帶的插件,這里進行了覆蓋設置;設置 inherited(是否繼承)為 false;設置 phase 為 generate-resources、goal 為 effective-pom 的配置 output

<plugin>
  <artifactId>maven-help-plugin</artifactId>
  <inherited>false</inherited>
  <executions>
    <execution>
      <id>generate-effective-dependencies-pom</id>
      <phase>generate-resources</phase>
      <goals>
        <goal>effective-pom</goal>
      </goals>
      <configuration>
        <output>${project.build.directory}/effective-pom/spring-boot-dependencies.xml</output>
      </configuration>
    </execution>
  </executions>
</plugin>

# xml-maven-plugin:處理XML相關

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>xml-maven-plugin</artifactId>
  <version>1.0</version>
  <inherited>false</inherited>
  <executions>
    <execution>
      <goals>
        <goal>transform</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <transformationSets>
      <transformationSet>
        <dir>${project.build.directory}/effective-pom</dir>
        <stylesheet>src/main/xslt/single-project.xsl</stylesheet>
        <outputDir>${project.build.directory}/effective-pom</outputDir>
      </transformationSet>
    </transformationSets>
  </configuration>
</plugin>

# build-helper-maven-plugin:用于設置主源碼目錄、測試源碼目錄、主資源文件目錄、測試資源文件目錄等

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <inherited>false</inherited>
  <executions>
    <execution>
      <id>attach-artifacts</id>
      <phase>package</phase>
      <goals>
        <goal>attach-artifact</goal>
      </goals>
      <configuration>
        <artifacts>
          <artifact>
            <file>${project.build.directory}/effective-pom/spring-boot-dependencies.xml</file>
            <type>effective-pom</type>
          </artifact>
        </artifacts>
      </configuration>
    </execution>
  </executions>
</plugin>

這三個插件共同完成了一件事,將 spring-boot-dependencies(springboot在項目里使用到的依賴)輸出到 XML,并且打包 install到倉庫。

這些就是spring-boot-dependencies 主要的作用了,管理控制依賴版本號,管理控制插件版本號以及引入了 3 個輔助插件。

4、對 spring-boot-dependencies 依賴管理方法的借鑒

spring-boot-dependencies 對依賴的管理方法,我們也可以借鑒一下。

spring-boot-dependencies 只管理著部分依賴,還有一些第三方依賴沒有管理到,當我們創(chuàng)建微服務時,就可以使用這種方法來管理父類的 POM 文件,把依賴的版本號集中在主POM中管理,其他子項目只需要在使用的時候引入即可,無需寫版本號。

單項目,那就沒有這么管理的必要了,不要為了管理而管理。

總結一下,spring-boot-dependencies 對插件的管理方法為:文章來源地址http://www.zghlxwxcb.cn/news/detail-531420.html

<!--版本號管理 start -->
<properties>
<test.version>5.5.2</test.version>
<plugin.version>5.5.2</plugin.version>
</properties>
<!--版本號管理 end -->

<!-- 依賴管理 start -->
<dependencyManagement>
<dependencies>
<groupId>xxxx</groupId>
<artifactId>xx-maven-plugin</artifactId>
<version>${test.version}</version>
</dependencies>
</dependencyManagement>
<!-- 依賴管理 end-->

<!-- 插件管理 end-->
<pluginManagement>
<plugins>
<groupId>xxxx</groupId>
<artifactId>xxxxxxx</artifactId>
<version>${plugin.version}</version>
</plugins>
</pluginManagement>
<!-- 插件管理 end-->

到了這里,關于SpringBoot:模塊探究之spring-boot-dependencies的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • 探究Spring Boot 中實現跨域的幾種方式

    探究Spring Boot 中實現跨域的幾種方式

    在現代Web應用中,由于安全性和隱私的考慮,瀏覽器限制了從一個域向另一個域發(fā)起的跨域HTTP請求。解決這個問題的一種常見方式是實現跨域資源共享(CORS)。Spring Boot提供了多種方式來處理跨域請求,本文將介紹其中的幾種方法。 Spring Boot提供了一個注解 @CrossOrigin ,可以

    2024年02月05日
    瀏覽(19)
  • 【Spring Boot】Spring Boot結合MyBatis簡單實現學生信息管理模塊

    環(huán)境準備 JDK Spring Boot MyBatis 創(chuàng)建Spring Boot項目 使用Spring Initializr創(chuàng)建一個新的Spring Boot項目,并添加以下依賴: Spring Web MyBatis Framework MySQL Driver 數據庫設計 在MySQL數據庫中創(chuàng)建一個名為 studentdb 的數據庫,并創(chuàng)建一個名為 students 的表,表結構如下:

    2024年02月11日
    瀏覽(93)
  • Spring Boot多模塊項目打包

    Spring Boot多模塊項目打包

    例如父項目 build_test 下面有三個子模塊,一個是common模塊 一個是a模塊,一個b模塊;其中common是公共模塊,a和b都依賴于公共模塊common,我現在想把a和b模塊打包成jar包。 創(chuàng)建父工程 創(chuàng)建3個子模塊,分別是common和a和b模塊 鼠標右擊紅框位置 選New 再選Module,鼠標左鍵點一下, 同

    2024年02月09日
    瀏覽(24)
  • spring boot 新建多模塊項目

    spring boot 新建多模塊項目

    1、新建項目 然后 下一步 完成 即可,如果完成后pom.xml里面的springboot版本報錯,則將版本修改為2.6.6即可解決,可能是新的版本沒那么穩(wěn)定,更換成老的版本就不報錯了。 新建好后,文件結構只保留pom.xml以及idea必須文件,如下圖: pom.xml中,作為模塊項目的父項目,groupId、

    2023年04月09日
    瀏覽(13)
  • Spring Boot多模塊項目的創(chuàng)建和配置(Maven工程多模塊)

    Spring Boot多模塊項目的創(chuàng)建和配置(Maven工程多模塊)

    在進行分布式系統開發(fā)時,我們通常會創(chuàng)建多個模塊的工程項目。即每一個功能就是一個Spring Boot工程,作為一個個模塊,然后這些模塊都會有一個父模塊,父模塊通常沒有代碼只有一個 pom.xml 。 今天就來分享一下Spring Boot如何創(chuàng)建一個多模塊項目,以創(chuàng)建一個兩個子模塊的

    2024年02月12日
    瀏覽(19)
  • Spring boot easyexcel 實現復合數據導出、按模塊導出

    Spring boot easyexcel 實現復合數據導出、按模塊導出

    場景: 導出數據為1對多的復合數據 一個模塊是一條數據,直接填充數據無法實現 如圖: 紅框內為一條數據(1對多),下方箭頭指向為第二條數據 如果直接填充,只能填充第一條,第二條就沒辦法了。 由于多行都包含許多,固定表頭,只能走填充路線,怎么實現呢 實現思路

    2024年02月07日
    瀏覽(19)
  • 網頁版Java(Spring/Spring Boot/Spring MVC)五子棋項目(四)對戰(zhàn)模塊

    網頁版Java(Spring/Spring Boot/Spring MVC)五子棋項目(四)對戰(zhàn)模塊

    匹配成功返回數據 1. message消息類別 2. ok 3. reson 4. 房間id 5. 雙方id 6.白色玩家 一個類記錄房間中的信息(房間id,兩個用戶id,是否為白棋) 信息提示框 處理匹配API 初始化游戲(棋盤,下一個棋子,接受棋子處理響應,判斷是否結束) 1. 客戶端連接到游戲房間后, 服務器返回

    2024年02月13日
    瀏覽(20)
  • spring boot3單模塊項目工程搭建-下(個人開發(fā)模板)

    spring boot3單模塊項目工程搭建-下(個人開發(fā)模板)

    ??個人主頁:? ? ?蒾酒 ??系列專欄 :《spring boot實戰(zhàn)》 目錄 寫在前面 上文銜接 常用依賴介紹以及整合 web組件 測試組件 樣板代碼生成 數據庫連接器 常用工具包 面向切面編程 ORM框架 數據連接池 接口測試、文檔導出 緩存中間件 參數校驗 認證鑒權 基礎功能完善 跨域問

    2024年04月28日
    瀏覽(39)
  • spring boot3單模塊項目工程搭建-上(個人開發(fā)模板)

    spring boot3單模塊項目工程搭建-上(個人開發(fā)模板)

    ? ??個人主頁:? ? ?蒾酒 ??系列專欄 :《spring boot實戰(zhàn)》 目錄 寫在前面 上文銜接 常規(guī)目錄創(chuàng)建 common目錄 exception.handle目錄 result.handle目錄 controller目錄 service目錄 mapper目錄 entity目錄 test目錄 寫在最后 本文介紹了springboot開發(fā)后端服務,單模塊項目工程搭建。單模塊搭建出

    2024年04月29日
    瀏覽(21)
  • 【Spring Boot】Spring Boot項目中如何查看springBoot版本和Spring的版本

    【Spring Boot】Spring Boot項目中如何查看springBoot版本和Spring的版本

    在項目中查看默認版本有兩種方式如下 Spring Boot 的最新版本支持情況: 版本 發(fā)布時間 停止維護時間 停止商業(yè)支持 3.0.x 2022-11-24 2023-11-24 2025-02-24 2.7.x 2022-05-19 2023-11-18 2025-02-18 2.6.x 2021-12-17 2022-11-24 2024-02-24 2.5.x 2021-05-20 已停止 2023-08-24 2.4.x 2020-11-12 已停止 2023-02-23 2.3.x 2020-05-

    2024年02月11日
    瀏覽(44)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包