What is Spring's Minimum Dependencies for Dependency Injection?

拜拜、爱过 提交于 2020-01-02 04:04:06

问题


What are the minimum dependencies required to just use Spring's dependency injection (core framework only)? I'm using Spring for a standalone application, and I'd like to minimize the number of dependencies that I have to ship with the application.

I suppose I could systematically remove a Jar and see if the application breaks, but it would be much better if someone had a definitive answer.

Oh, and I'm using Spring 2.5.


回答1:


Check out the readme.txt that comes with the download of Spring 2.5.

Assuming you don't have AOP, JDBC, Transactions, or ORM, then your best bet is probably:

  • spring-core
  • spring-beans
  • spring-context



回答2:


If your are using maven then only spring-context is needed in your pom.xml, it depends on aop, beans, core, expression and asm




回答3:


I think for today it is more convenient to use spring-boot, coming out of this idea my suggestion is to use "org.springframework.boot:spring-boot-starter"

below is dependencies tree:

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


来源:https://stackoverflow.com/questions/877312/what-is-springs-minimum-dependencies-for-dependency-injection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!