Started by Chris GillNov 5, 2021

Open
How to load beans according to Spring java conf from jar dynamically?

0 VIEWES 0 LIKES 0 DISLIKES SHARE
0 LIKES 0 DISLIKES 0 VIEWES SHARE

I have such app conf in, jar so that you can be brought to the classpath after startup:

@Configuration
@ComponentScan("com.transportexchangegroup.testConf")
public class AppConf {
   
}

How to load beans dynamically? I saw solutions whilst it's miles required to jot down and upload bean definitions, but if we do not recognize everything approximately new beans and simply need to load them routinely?

Class conf = jarService.loadClass("com.x.testConf.AppConf");
((AnnotationConfigServletWebServerApplicationContext) applicationContext).register(conf);
((AnnotationConfigServletWebServerApplicationContext) applicationContext).refresh();

As I see, refresh() turns off web app started locally from IDE.

0 Replies

You must be Logged in to reply
Techiio

Techiio is on the journey to build an ocean of technical knowledge, scouring the emerging stars in process and proffering them to the corporate world.

Follow us on:

facebooklinkdeintwitter

Subscribe to get latest updates

You can unsubscribe anytime from getting updates from us
Copyright techiio.com @2020 Kolkata, India
made with by Abhishek & Priyanka Jalan
Copyright techiio.com @2020
made with by Abhishek & Priyanka Jalan