在我的应用程序中,我想加载动态类。我添加了如下代码片段,
private static Class clazz;
在实现类的方法中,
clazz = (Class) applicationContext.getBean("arrived class name for thirty party");
在应用程序中获取类的方法是否有效?
如果它的对象重新注册并且您需要该 bean 的类名
clazz = applicationContext.getBean("arrived class name for thirty party").getClass();
如果它的 String 值注册为 bean 并且你需要它的类实例
clazz = Class.forName(applicationContext.getBean("arrived class name for thirty party"));
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);