Following is sample class named 'Item' and It has one field named 'itemShop'.
Class Item{
@Autowired
Shop itemShop;
...
...
}
Main(){
Item item1 = new Item();
Item item2 = new Item();
// item1 and item2 both should have same 'itemShop' object.
}
I want that for all objects item1,item2 ... item_n, I have only one instance of 'itemShop'. I am new in Java and I want to know is there any way I can use 'Autowired' annotation to have single instance of 'itemShop' field in whole program.