Reputation: 37
In my application I want to load dynamic classes. I added the code snippet like below,
private static Class clazz;
In the method of the implemented class,
clazz = (Class) applicationContext.getBean("arrived class name for thirty party");
Is approach valid to get the class in the application?
Upvotes: 1
Views: 809
Reputation: 2255
You can use - clazz = applicationContext.getBean("arrived class name for thirty party",.class);
ex- Employee emp = ctx.getBean("arrived class name for thirty party", Employee.class);
Upvotes: 0
Reputation: 240870
if its object reistered and you need class name of that bean
clazz = applicationContext.getBean("arrived class name for thirty party").getClass();
if its String value registered as bean and you need its class instance
clazz = Class.forName(applicationContext.getBean("arrived class name for thirty party"));
Upvotes: 1