Reputation: 11
I have a class A and class B which are using methods from class C.
Class C is a service class annotated with @Service.
To get object instances of class C in class A and B, I have used @Autowired.
This means that Spring will create two object instances, one for class A and one for class B ?
Upvotes: 1
Views: 523
Reputation: 16529
No, Spring creates singleton (default scope) bean in the IOC container.
So, only one bean will be created for class C.
That particular bean or object of class C will be shared for all the classes whether it's class A or B or whatever.
Upvotes: 2