I have a spring boot application that contains some machine learning Weight files? I want to know does spring boot Initializes the class on Container Startup? Or does it do this when a certain request Comes in? I don't want to parse those files everytime HTTP request comes in? Is their a way i read those files once and use them on every request?
Asked
Active
Viewed 586 times
0
-
you can refer below link https://stackoverflow.com/questions/27405713/running-code-after-spring-boot-starts?answertab=oldest#tab-top – ManojP Jan 02 '18 at 11:33
1 Answers
1
You can write custom class like this
@Component
public class ApplicationStartup
implements ApplicationListener<ApplicationReadyEvent> {
/**
* This event is executed as late as conceivably possible to indicate that
* the application is ready to service requests.
*/
@Override
public void onApplicationEvent(final ApplicationReadyEvent event) {
// here your code ...
return;
}
}

ManojP
- 6,113
- 2
- 37
- 49