Describe the bug
IdmBootstrapper using event.getApplicationContext().getParent() == null to avoid multiple child contexts refreshed event, but in my project, create admin user not be triggered. maybe because i use nacos as configuration, all ApplicationContext has a parent?
I change the code as fowllowing, it works well.
@Autowired
ApplicationContext applicationContext;
@EventListener
public void onApplicationEvent(ContextRefreshedEvent event) {
if (event.getApplicationContext().equals(this.applicationContext)) {
System.out.println("Fired only once!");
}
}
Code
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if (event.getApplicationContext().getParent() == null) { // Using Spring MVC, there are multiple child contexts. We only care about the root
if ((ldapProperties == null || !ldapProperties.isEnabled()) && !idmAppProperties.getKeycloak().isEnabled()) {
if (idmAppProperties.isBootstrap()) {
// First create the default IDM entities
createDefaultAdminUserAndPrivileges();
}
} else {
Describe the bug IdmBootstrapper using
event.getApplicationContext().getParent() == null
to avoid multiple child contexts refreshed event, but in my project, create admin user not be triggered. maybe because i use nacos as configuration, all ApplicationContext has a parent? I change the code as fowllowing, it works well.Code
Additional context Flowable: 6.7.2 Springboot: 2.6.2