In the search, scan and register all components after loading the jar file at runtime using the URLClassLoader
jar file just contains a class annotated with @Component etc ... I tried
GenericBeanDefinition bd = new GenericBeanDefinition();
bd.setBeanClass(MyClass.class);
beanFactory.registerSingleton("myBean", bd);
and
ConfigurableListableBeanFactory beanFactory = ((ConfigurableApplicationContext) ctx).getBeanFactory();
beanFactory.createBean(MyClass.class);
but it doesn’t work, is there any for this?
source
share