File-based (XML) versus code-based configuration

The benefit of XML-based configuration is that you can alter dependencies without recompiling, building, and deploying the application code. This sounds useful in a situation where you need to swap the dependencies of the same type. But again, is this really what you are looking for? In other words, if you do not have the requirements for changing the implementation of dependencies on the fly at runtime, then file-based configuration is not that useful.

On the downside, file-based configuration is generally more difficult to read and analyze, especially when it becomes large and clumsy. XML-based configuration does not warn you about any errors at compile time. Such errors can only be picked ...

Get Java 9 Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.