簡體   English   中英

Spring 對依賴注入的最小依賴是什么?

[英]What is Spring's Minimum Dependencies for Dependency Injection?

僅使用 Spring 的依賴注入(僅限核心框架)所需的最小依賴是什么? 我將 Spring 用於一個獨立的應用程序,我想盡量減少我必須隨應用程序一起提供的依賴項的數量。

我想我可以系統地刪除一個 Jar 並查看應用程序是否中斷,但如果有人有明確的答案會更好。

哦,我使用的是 Spring 2.5。

查看下載 Spring 2.5 附帶的readme.txt

假設您沒有 AOP、JDBC、事務或 ORM,那么您最好的選擇可能是:

  • 彈簧芯
  • 春豆
  • 彈簧上下文

如果您使用的是 maven,那么 pom.xml 中只需要 spring-context,這取決於 aop、bean、核心、表達式和 asm

我認為今天使用spring-boot更方便,從這個想法出來我的建議是使用“org.springframework.boot:spring-boot-starter”

下面是依賴樹:

compile - Dependencies for source set 'main' (deprecated, use 'implementation' instead).
\--- org.springframework.boot:spring-boot-starter:2.1.2.RELEASE
     +--- org.springframework.boot:spring-boot:2.1.2.RELEASE
     |    +--- org.springframework:spring-core:5.1.4.RELEASE
     |    |    \--- org.springframework:spring-jcl:5.1.4.RELEASE
     |    \--- org.springframework:spring-context:5.1.4.RELEASE
     |         +--- org.springframework:spring-aop:5.1.4.RELEASE
     |         |    +--- org.springframework:spring-beans:5.1.4.RELEASE
     |         |    |    \--- org.springframework:spring-core:5.1.4.RELEASE (*)
     |         |    \--- org.springframework:spring-core:5.1.4.RELEASE (*)
     |         +--- org.springframework:spring-beans:5.1.4.RELEASE (*)
     |         +--- org.springframework:spring-core:5.1.4.RELEASE (*)
     |         \--- org.springframework:spring-expression:5.1.4.RELEASE
     |              \--- org.springframework:spring-core:5.1.4.RELEASE (*)
     +--- org.springframework.boot:spring-boot-autoconfigure:2.1.2.RELEASE
     |    \--- org.springframework.boot:spring-boot:2.1.2.RELEASE (*)
     +--- org.springframework.boot:spring-boot-starter-logging:2.1.2.RELEASE
     |    +--- ch.qos.logback:logback-classic:1.2.3
     |    |    +--- ch.qos.logback:logback-core:1.2.3
     |    |    \--- org.slf4j:slf4j-api:1.7.25
     |    +--- org.apache.logging.log4j:log4j-to-slf4j:2.11.1
     |    |    +--- org.slf4j:slf4j-api:1.7.25
     |    |    \--- org.apache.logging.log4j:log4j-api:2.11.1
     |    \--- org.slf4j:jul-to-slf4j:1.7.25
     |         \--- org.slf4j:slf4j-api:1.7.25
     +--- javax.annotation:javax.annotation-api:1.3.2
     +--- org.springframework:spring-core:5.1.4.RELEASE (*)
     \--- org.yaml:snakeyaml:1.23

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM