Saturday, 15 May 2010

java - How do you cause Spring to inject into/call setters of a Spring annotated class? -



java - How do you cause Spring to inject into/call setters of a Spring annotated class? -

is there way add together annotations class below specify spring inject instances bean bar?

@scope("prototype") @component("vnetwork-start") //how inject bar value? public class vnetworkstartcommand extends vnetworkcommand { public vnetworkstartcommand() { super(vnetworkcommandtype.start); } @required public void setbar(bar bar) { system.out.println("bar="+bar); } }

annotate method spring's @autowired, or javax.inject's @inject, or javax.annotation's @resource.

this assumes annotation configuration enabled , bar bean available in context.

java spring annotations

No comments:

Post a Comment