I suggest to use SpringApplicationRunListener:
class AppListenerExcluder implements SpringApplicationRunListener {
AppListenerExcluder(SpringApplication app, String[] args) {
app.setListeners(
app.getListeners().stream()
.filter(not(listener -> listener instanceof UnwantedListener))
.toList());
}
}
We have to declare It in spring.factories in app "resources" folder:
src
ㅤmain
ㅤㅤresources
ㅤㅤㅤMETA-INF
ㅤㅤㅤㅤspring.factories
ㅤㅤㅤㅤㅤorg.springframework.boot.SpringApplicationRunListener=\
ㅤㅤㅤㅤ ㅤdev.rost.client.config.AppListenerExcluder
GitHub 🔗