java - How does Spring create different instances of a specific type of bean based on the parameters passed in at startup and call these instances in subsequent business?
学习ing
学习ing 2017-06-23 09:12:52
0
1
752

Note that instead of simply configuring the bean scope into multiple instances, you need to create different instances according to different parameters at startup. These created instances need to be called in subsequent business Example.
My current idea is to use factoryBean to proxy the abstracted parent class, and then configure the concretely implemented subclasses into different instances in the xml file. However, in this way, the parameters may be dynamically read from the database. Second, the number of generated instances cannot be determined, so I don’t know if there is any other way?

学习ing
学习ing

reply all(1)
曾经蜡笔没有小新

You can read the database at startup, then put the multiple generated instances into a HashMap, and then provide a method to get the instance objects based on the type. No need to make it @Bean

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template