I have read here that using is considered applicationContext.getBean("somebeananmehere") is bad.
if that so, how would I programmatically get beans (depends on the user on what kind of bean he wants, let's say he can choose different grocery items eg apple,soap,detergent)?
let's say
switch(num){
case 1 : myGrocery = (GroceryItem) applicationContext.getBean("SOAP");break;
case 2: myGrocery = (GroceryItem) applicationContext.getBean("APPLE");break;
default:
//more code here
}
this is what I am doing in my application where the user is selecting his or her grocery items. (This is a console application)
if applicationContext.getBean is considered bad, then what is the alternative ?