Rudziankoŭ
Rudziankoŭ

Reputation: 11251

What spring-beans and spring-context are used for?

I am just curious about what <groupId>org.springframework</groupId <artifactId>spring-beans</artifactId> dependency is used for? The same question is about spring-context.

I don't see explicit dependencies on this module. How are they used by spring? Why aren't they included into spring-core?

Upvotes: 1

Views: 79

Answers (1)

Arne Burmeister
Arne Burmeister

Reputation: 20594

Spring Framework is separated to clarify and minimise dependencies of their parts and you can minimise the needed dependencies of your project. All the three libraries you mentioned are part of the core container where spring-context depends on spring-beans and spring-beans depends on spring-core. Some Spring libraries have fewer dependencies like spring-expression only depending on core but not on beans or context:

spring-context
+- spring-beans
   +- spring-core

spring-expression
+- spring-core

spring-webmvc
+- spring-web
   +- spring-context
   \- spring-aop
+- spring-context
\- spring-expression

(simplified, not showing all transitive dependencies, when using maven try mvn dependency:tree)

So the maintainer of spring-expression only has to deal with spring-core. Less dependencies make responsibilities and possibilities more clear. And it prevents you from using "all" available which makes getting rid of deprecated APIs much more difficult. Each of the libraries has it's own (non Spring) dependencies. To upgrade any of them would become hard if everyone in the Spring ecosystem and any project depending on Spring would simply directly depend of all. One of the reasons most OpenSource libraries moved away from that '*-all" dependency style to separate modules with clear dependencies on each other.

For more explanation see also the official Introduction to the Spring Framework : Core Container.

Upvotes: 1

Related Questions