SqlSessionFactoryBean falls in circular dependencies by Spring Boot's DataSourceInitializer.
With @Lazy annotations it's okay but without them the following exception occurs:
Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSessionFactory': Requested bean is currently in creation: Is there an unresolvable circular reference?
A project with @Lazy annotations:
https://github.com/izeye/samples-spring-boot-branches/tree/mybatis-hsqldb
A project without @Lazy annotations:
https://github.com/izeye/samples-spring-boot-branches/tree/mybatis-hsqldb-without-lazy
I guess replacing ApplicationListener<ApplicationEvent> with ApplicationListener<ContextRefreshedEvent> would fix it.
If my usage is incorrect, please let me know.