4 1 | Is possible in Spring that class for bean doesn't have public constructor but only private ? Will this private constructor invoked when bean is created? Thanks.
| ||||||
feedback |
7 | Yes, Spring can invoke private constructors. If it finds a constructor with the right arguments, regardless of visibility, it will use reflection to set its constructor to be accessible. | ||||||||||||
feedback |
2 | You can always use a factory method to create beans rather than relying on a default constructor, fromThe IoC container: Instantiation using an instance factory method:
This has the advantage that you can use non-default constructors for your bean, and the dependencies for the factory method bean can be injected as well. | ||||||||||||
|
'via Blog this'