Keeping your Spring configuration light

One of the problems with Spring before annotations was the size of the application context XML files. Application context XML files ran into hundreds of lines (sometimes, even thousands of lines). However, with annotations, there is no need for such long application context XML files anymore.

We recommend that you use component scans to locate and autowire the beans instead of manually wiring the beans in XML files. Keep your application context XML files very small. We recommend that you use Java @Configuration wherever some framework-related configuration is needed.

Get Mastering Spring 5.0 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.