vendredi 7 août 2020

How to use Java reflection to create an instance of an @Autowired class

I have a postgres database which stores (as a String) the relevant class to use dependent on the information coming in from the user.

e.g. user has input Name, the database has the value NameFinder() stored against this and the code needs to create an instance of NameFinder().

I was wondering if there was a way of using reflection to instantiate this class as an @Autowired component, and then call the relevant function.

I can't seem to find a guide that uses @Autowired classes so any help would be appreciated.





Aucun commentaire:

Enregistrer un commentaire