Pages

Monday, January 18, 2016

Auto-Wiring of Optional Beans with Spring using JSR-330

I've been using Spring for years and particularly like how little intrusive the framework is. For that reason I even still use the XML configuration option in order to have as little dependencies on the Spring framework as possible in my code. I also used to prefer explicit bean wiring over auto-wiring for the same reason, @Autowire is Spring annotation I tried to avoid; and also I have a tendency of being a control freak and didn't want some magic to determine my application setup. Not having a dependency on Spring is particularly important in my current project for various reasons. However, I'm over my control-freak attitude and with the arrival of JSR-330 I can get it all: Auto-wiring as well as JDK-only annotations/classes.