nerdexam
Broadcom-VMware

2V0-72.22PSE · Question #78

Refer to the exhibit. Which two statements are correct regarding auto-configuration of DataSource and JdbcTemplate beans given a Spring Boot application with only these two dependencies? (Choose two.)

The correct answer is C. A JdbcTemplate bean will be auto-configured. E. A DataSource bean will be auto-configured. When Spring Boot detects spring-boot-starter-jdbc (or spring-jdbc) on the classpath along with an embedded database driver like H2, HSQLDB, or Derby, it automatically wires up both a DataSource bean (pointing to the embedded DB) and a JdbcTemplate bean (using that DataSource)…

Data Access

Question

Refer to the exhibit. Which two statements are correct regarding auto-configuration of DataSource and JdbcTemplate beans given a Spring Boot application with only these two dependencies? (Choose two.)

Exhibit

2V0-72.22PSE question #78 exhibit

Options

  • AA DataSource bean will not be auto-configured.
  • BA JdbcTemplate bean will not be auto-configured.
  • CA JdbcTemplate bean will be auto-configured.
  • DA DataSource bean will be auto-configured only if a JdbcTemplate bean is explicitly defined.
  • EA DataSource bean will be auto-configured.

How the community answered

(23 responses)
  • A
    4% (1)
  • C
    91% (21)
  • D
    4% (1)

Explanation

When Spring Boot detects spring-boot-starter-jdbc (or spring-jdbc) on the classpath along with an embedded database driver like H2, HSQLDB, or Derby, it automatically wires up both a DataSource bean (pointing to the embedded DB) and a JdbcTemplate bean (using that DataSource) - making C and E correct. No manual @Bean definitions are needed; Spring Boot's DataSourceAutoConfiguration and JdbcTemplateAutoConfiguration handle this entirely.

Why the distractors are wrong:

  • A is the direct opposite of the truth - the embedded DB on the classpath is exactly what triggers DataSource auto-configuration.
  • B is wrong because JdbcTemplateAutoConfiguration fires whenever a DataSource bean is present (auto-configured or otherwise).
  • D inverts the actual dependency: JdbcTemplate depends on DataSource, not the other way around. DataSource is configured independently and does not care whether a JdbcTemplate exists.

Memory tip: Think of it as a chain - embedded DB driver → DataSource → JdbcTemplate. If the first link is on the classpath, Spring Boot auto-builds the whole chain. You only need to break the chain yourself (with spring.datasource.* properties) if you want a non-embedded database.

Topics

#Spring Boot auto-configuration#DataSource#JdbcTemplate#JDBC

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice