Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the minimal amount of Spring dependencies a library can have?

Tags:

java

spring

We have several Java services that are wired together with Spring, and many jars shared between these services that provide @Components.

Due to pervasive copy and pasting, the pom files for the component jars have ended up with the full list of Spring dependencies that the full services require.

What is the recommended minimal set of Spring dependencies that a shared jar should have?

like image 360
Adam Vandenberg Avatar asked Oct 19 '25 09:10

Adam Vandenberg


2 Answers

What is the recommended minimal set of Spring dependencies that a shared jar should have?

I don't think there is one as it depends on the scope of your shared JAR. If the JAR contains classes covering aspects of different layers (persistence, presentation, etc.) you may need "everything". In the worst case and if it's really complex, reverse-engineering may be your last resort: remove all dependencies not required at compile time and then test, test, test... I know - painful :-)

like image 191
home Avatar answered Oct 21 '25 22:10

home


None. Spring being non-invasive does not require adding any compile-time dependencies. But when you use more specific features:

  • the stereotype annotations are in spring-context, if you use them (@Component).
  • @Autowired is in spring-beans
  • for everything else - it depends on what you use

Note that this is for compile time. When you run it you will need at least spring-core, but that should be defined by the application that uses ghe jars

like image 21
Bozho Avatar answered Oct 21 '25 21:10

Bozho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!