I'm running into a dependency issue. Basically, my Spring Dao @Component is dependent on another Spring @Component injected via a setter and it isn't always there (is null). I could use @Required or the InitializingBean interface to check whether the dependent component is there but that doesn't actually create the component, just tells me whether it's available or not.

I have over 60 Dao @Component beans and they all have a dependency on that one object. I don't want to declare every single one of them using XML and then use the depends-on attribute. It's too much of a pain.

Is it possible that I can ensure that that particular component is created before all the rest?

One "idea" I had was to declare the dependent component using XML and all the rest using @Component. Would declaring a component using XML ensure that it's created before any of the ones using annotations?

Thanks. Any help is appreciated.