开发者

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

We have several Java services that are wired together with Spring,开发者_StackOverflow中文版 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?


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 :-)


Typically it is two: Spring core and Spring security. If you are not using Spring security than core will be plenty too get you through.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜