why not D ?
even if it is singleton because ther are no scope , the bean is still instantiated twice because it is called twice by two different @Bean methods (transferService() and accountService()).
A. One AccountRepository bean will be instantiated since the default scope is singleton.
In Spring, when a method annotated with @Bean is called multiple times within the same application context, the Spring container manages the bean instances based on the method's scope. By default, the scope of a @Bean method is singleton, which means Spring will create and manage a single instance of the bean within the application context. Regardless of how many times the method is called, only one instance of the bean will be created and managed by Spring.
Also, Spring intercepts the call to the bean factory method and first checks if the singleton is already created. So it makes no difference if accountRepository() is called or if a parameter of type AccountRepository is used in transferService()/accountService()
upvoted 1 times
...
...
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
Tolo01
5 months, 3 weeks agorhuanca
10 months agonesreenmhd123
3 months, 2 weeks agozakupower
10 months, 2 weeks agoquakquak3
1 month, 1 week ago