Eduardo
Eduardo

Reputation: 2280

Spring Boot load order when multiple classes implement SmartInitializingSingleton

I have two classes

@Component
@DependsOn("A")//I added this annotation to execute first B.afterSingletonsInstantiated() but it does not work
public class B implements SmartInitializingSingleton {

    @Override
    public void afterSingletonsInstantiated() {
        log.info("B");
    }
}

@Component
public class A implements SmartInitializingSingleton {

    @Override
    public void afterSingletonsInstantiated() {
        log.info("A");
    }
}

The question is, how can I specify one has to execute its overridden method before the other?

Upvotes: 0

Views: 34

Answers (0)

Related Questions