springboot version: 2.7.0

Minimal repo https://github.com/yzqbugs/spring-bugs

Instead of using spring.factories i use the new /META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports while it doesn't seem to work. using spring.factories works well then.

My listener

@AutoConfiguration
@Slf4j
public class ConstantsInitListener implements ApplicationListener<ApplicationContextInitializedEvent>, Ordered {



    @Override
    public int getOrder() {
        return Ordered.HIGHEST_PRECEDENCE;
    }

    @Override
    public void onApplicationEvent(ApplicationContextInitializedEvent applicationContextInitializedEvent) {
        log.info("listener start");
        System.out.println(ConstantsInitListener.class.getName());
    }
}

My autoimport file

#/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
com.example.springbugs.listener.ConstantsInitListener

It should print listener start, but it not.

Comment From: scottfrederick

Configuration classes annotated with @AutoConfiguration or @Configuration should contribute beans to the application context (typically with @Bean-annotated methods in the configuration class). Your ConstantsInitListener class is not a configuration class, and should not be annotated with @AutoConfiguration. Instead it should be listed in spring.factories as an ApplicationListener:

org.springframework.context.ApplicationListener=\
com.example.springbugs.listener.ConstantsInitListener