Reputation: 2846
is there a way to add annotations to the class below to specify to Spring to inject into the instances a bean for bar?
@Scope("prototype")
@Component("vnetwork-start")
//how to inject bar value?
public class VNetworkStartCommand extends VNetworkCommand {
public VNetworkStartCommand() { super(VNetworkCommandType.START); }
@Required public void setBar(Bar bar) { System.out.println("bar="+bar); }
}
Upvotes: 0
Views: 39
Reputation: 279890
Annotate the method with Spring's @Autowired
, or javax.inject
's @Inject
, or javax.annotation
's @Resource
.
This obviously assumes that annotation configuration is enabled and a Bar
bean is available in the context.
Upvotes: 1