Question 1
With spring-boot-starter-data-jpa on the classpath and an embedded database present, what does Spring Boot auto-configure?
A. A DataSource, an EntityManagerFactory, a JpaTransactionManager, and Spring Data repository scanningCorrect answer
The JPA starter auto-configures the full stack — an embedded DataSource, a JPA EntityManagerFactory (Hibernate by default), a JpaTransactionManager, and scanning for Spring Data repository interfaces — so a basic app needs no manual wiring.
B. Only a DataSource; the EntityManagerFactory must be declared manually
Understates auto-configuration: the EntityManagerFactory is auto-configured as well, not something you must declare by hand.
C. A JdbcTemplate but no JPA infrastructure
Names the wrong infrastructure: the JPA starter configures JPA components such as the EntityManagerFactory and transaction manager, not merely a JdbcTemplate.
D. Nothing — JPA always requires a hand-written persistence.xml and manual wiring
Denies auto-configuration entirely: Boot's auto-configuration removes the need for a hand-written persistence.xml and manual wiring in a basic app.
Explanation
With the JPA starter and an embedded database on the classpath, Spring Boot auto-configures the entire persistence stack — a DataSource, a JPA EntityManagerFactory backed by Hibernate, a JpaTransactionManager, and scanning for Spring Data repository interfaces. A basic application therefore runs without any hand-written persistence.xml or manual bean wiring.