什么是Spring对依赖注入的最小依赖性?

时间:2009-05-18 11:43:43

标签: java spring dependency-injection

使用Spring的依赖注入(仅限核心框架)所需的最小依赖项是什么?我使用Spring作为一个独立的应用程序,我想尽量减少我必须随应用程序提供的依赖项数量。

我想我可以系统地删除一个Jar并查看应用程序是否中断,但如果有人有明确的答案会更好。

哦,我正在使用Spring 2.5。

3 个答案:

答案 0 :(得分:8)

查看Spring 2.5下载附带的readme.txt

假设您没有AOP,JDBC,Transactions或ORM,那么最好的选择可能是:

  • 弹簧芯
  • 弹簧豆
  • 弹簧上下文

答案 1 :(得分:0)

如果您正在使用Maven,则pom.xml中仅需要spring-context,它取决于aop,bean,core,expression和asm

答案 2 :(得分:-1)

我认为今天使用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
相关问题