42

Hello I am new to the Spring and maven world, and I want to know what is the difference between this 2 dependencies?

Its a simple question.. I am having trouble with my pom.xml file, so I want to know everything :).

Thanks in advance.

HDJEMAI
  • 9,436
  • 46
  • 67
  • 93
Juano7894
  • 703
  • 1
  • 8
  • 21

1 Answers1

49

These are actually 2 of many Spring Framework modules. You can easily find what packages these artifacts contain, using this site:

http://mvnrepository.com/artifact/org.springframework/spring-core/3.1.1.RELEASE

This can give you information about classes contained within a particular artifact and probably about the its purpose.

For Spring Framework, spring-core contains mainly core utilities and common stuff (like enums) and because it's really critical for Spring, probably all other Spring modules depend on it (directly or transitively).

In turn spring-context provides Application Context, that is Spring's Dependency Injection Container and it is probably always defined in POMs of artifacts that use Spring Framework somehow. In fact, spring-context depends on spring-core so by defining spring-context as your dependency, you have spring-core in your classpath as well.

Michał Kalinowski
  • 16,925
  • 5
  • 35
  • 48
  • So, `spring-core` and `spring-context` two separate dependencies is not need iin the same application? – susan097 Apr 28 '18 at 15:21
  • 1
    Probably they are, actually. As I explained, if you depend on `spring-context`, you depend on `spring-core` as well. – Michał Kalinowski Apr 30 '18 at 07:18
  • 2
    They are two different dependencies. As @Michał wrote, `spring-context` depends on `spring-core` so, Maven will get it as a transitive dependency. You can see such dependencies in `spring-context` Maven repository site: https://mvnrepository.com/artifact/org.springframework/spring-context/5.1.5.RELEASE So, `spring-core` is under **Compile Dependencies**, meaning that if you include `spring-context` in your POM file, you will also get `spring-core` as well, (...among others). – Oliver Mar 29 '19 at 23:49
  • `and probably about the its purpose` ?? – HDJEMAI May 19 '20 at 09:46
  • `and it is probably always defined` ?? – HDJEMAI May 19 '20 at 09:47