As a Junior
Java Developer, I've been encouraged to use Spring from the get-go.
However, so far I've seen many problems in using Spring, and not so many of the advantages.
Here are the drawbacks I've found:
- Using Spring, regular compile-time checking is disabled.
You can't use proper type-checking with getObject, you simply have to cast the result to what you expect, and risk a run-time cast exception.
I'm also not entirely sure why Spring isn't able to use the method many mocking frameworks use, and accept the expected class as an argument to avoid casts.
- Part of your application is now written/specified in XML, so many static checking tools can no longer operate on your code without specific support for spring.
This also means requiring things like strings of fully qualified classnames, that IDEs like eclipse can't automatically update or re-factor when a class is renamed or moved.
- classes written for spring need to be adapted for spring, and so do many libraries.
Using things easily with spring-support often requires a specific spring-version of that package. Using spring components outside of spring is difficult, and often classes written
for spring require refactoring to work as regular pojos again.
- exceptions are very verbose, and often unhelpful
For adding a plumbing framework on top of your code, you get exposed to a lot of the complexity whenever something goes wrong.
It's not unusually for an exception message to list *every* bean that failed to initialise.
Things like invalid XML, won't be reported as such (perhaps with a filename and line number), but rather with the failure of some kind of abstract class responsible for parsing the XML.
It's possible that I've picked up some mis-conceptions about Spring, but if this is that case, I'd certainly like those cleared up too.