views:

29

answers:

1

I've started using Spring 3 Java Config with the JSR-330 @Inject annotations. Unlike the Spring @Autowire, Spring does not fail at startup if the @Inject parameters are null. Is there a way to do this within Java Config?

Edit: Just a clarification, I would like this as the default behaviour so I don't have to put @Required on every field.

+1  A: 

I think you can use @Required on a setter for the dependency, in addition to @Inject.

Bozho
Sorry, I forgot to mention that I'd like it as the default behaviour without having to put @Required on all the fields.
Arthur Kalmenson
I guess there's no other way, thanks Bozho.
Arthur Kalmenson