Reputation: 7058
Spring boot provides many starter dependencies like spring-boot-starter, spring-boot-starter-batch, spring-boot-starter-test and many more. These dependencies include a lot of other transitive dependencies. So far, I was using these starter dependencies consitently in the project. Only where there was no starter dependency for a library, I included the concrete dependency.
Recently passed a colleague and said he did not want to integrate all these starter dependencies into the project. He had much rather control over the specific dependencies to be included and so you can ensure that only dependencies are on build and classpath that are actually needed.
I think that's the wrong approach, right? Are there any disadvantages of having dependencies on the classpath (e.g. hamcrest) that are not really needed?
Upvotes: 1
Views: 1016
Reputation: 1342
To be honest, I kind of agree with your colleague , + on what Ralph suggests on his answer. The tricky point is Spring boot. What I am trying to say is that the dependencies and project setup and the overall mechanism is highly dependent on ready made decisions and dependencies, provided by the Spring Boot framework. The moment you want to eventually escape of all these nice things that work out of the box, and specifically the dependency management etc, then IMHO , you bump into trouble. It would make sense if you restructure your Spring based application, trying to define your own project structure, all the required dependencies and of course wire all the required plugins on your own. But that would cost time and it would increase complexity...thats why Spring Boot and other frameworks tend to be opinionated on several aspects. To ease that kind of pain. It is really a matter of choise and how control you want to have in the future.
Upvotes: 0
Reputation: 44535
Generally i would agree with your colleague to keep your dependencies as clean as possible.
However, if you want to use any features related to Spring Boot, then i would advise you to use the starters, since they include all required dependencies and enable the necessary auto configuration classes. If you would define the dependencies and configuration yourself, there would be no point of using Spring Boot and you could ditch it.
Upvotes: 2
Reputation: 120811
You colleague is right. You should not have libs in the classpath that are not used at all. It makes the war bigger and the component scan slower. (It also make you IDE a bit slower.)
On the other hand, is is a lot of work to maintain all dependencies by your own, but I think it is worth.
Upvotes: 2