I have a question regarding the startup in spring boot
, how to close the application during the startup time, for example, I have the following
application.yml
:
ansi:
true
And I have the following @Configuration
class:
@Configuration
class AppConfig {
@Value('${ansi}')
String ansi;
@Bean
getAnsi() {
if(ansi.equals("true")) {
Ansi ansiObj = new Ansi();
ansiObj.ansi = ansi;
return ansiObj;
}
}
}
class Ansi {
String ansi;
}
When ansi
in the application.yml
is true
, it continue, otherwise, the application should be closed, can we close the application during the bean creation? is it a good practice? Are there any good ways to handle this?