Hibernate / MyBatis Interview questions
Explain the execution flow of MyBatis-Spring-Boot-Starter's auto-configuration?
When mybatis-spring-boot-starter is on the classpath of a Spring Boot application, its auto-configuration class activates automatically (conditioned on a DataSource bean being present) and wires up the SqlSessionFactory, mapper scanning, and related beans without requiring explicit XML or Java configuration for the common case.
The auto-configuration reads mybatis.* properties from application.properties/application.yml (like mybatis.mapper-locations and mybatis.configuration.* settings) to customize the generated SqlSessionFactory, and it scans the classpath for interfaces annotated with @Mapper, registering each one as a Spring bean via MapperFactoryBean so they can be injected anywhere in the application using standard @Autowired.
Because this entire process is conditional (Spring Boot's auto-configuration only activates when its preconditions, like a present DataSource bean, are actually met), a developer can still fall back to fully manual, explicit configuration — defining their own SqlSessionFactory bean, for instance — and Spring Boot's auto-configuration will back off automatically rather than conflicting with an explicitly user-defined bean of the same type.
More Related questions...