#1 constructor Injection vs properties Inject constructor: pro: accountRepository promote immutation; concise; constructor-arg can be in any order con: optional; describle; inherited automatically; cyclic references; #2 How to implement factory bean: factory-method; implement FactoryBean interface and the getObject() method (Auto-Detected by Spring Framework) #3 @PostConstruct and @PreDestory @PostConstruct can be used to add behavior at startup after spring finishing initiating the bean object @PreDestory before bean object being destored. The alternative in the xml configuration are init-method and destory-method Best practice: #1 Separate 'application" beans from "infrastructure" beans as infrastructure of changes between environments.
The reason for doing the work is to create something useful that helps people. Please click the ads if my articles are useful for you. Definitely, that's not enough. My target is working at some great organizations, such that one day, all the people with internet access can benefit from the service I contributed.