Exam 2v0-7222 All QuestionsBrowse all questions from this exam
Question 16

Refer to the exhibit.

The above code shows a conditional @Bean method for the creation of a JdbcTemplate bean.

Which two statements correctly describe the code behavior? (Choose two.)

    Correct Answer: A, E

    The @ConditionalOnBean annotation used in the code ensures that the JdbcTemplate bean will only be created if a bean named 'dataSource' already exists in the application context. This behavior is correctly described by the statement that a JdbcTemplate bean will be created when a bean named dataSource has already been created. Additionally, replacing @ConditionalOnBean(name= “dataSource”) with @ConditionalOnBean(DataSource.class) provides greater flexibility because it checks for the existence of a DataSource bean of any name in the context, rather than a bean with a specific name, making the code more adaptable.

Discussion
rhuancaOptions: AE

A and E Option D is incorrect because the @ConditionalOnBean annotation requires that a bean with the specified name or class already exists in the application context for the JdbcTemplate bean to be created.

EymetOptions: AE

Answer is AE

qqooOptions: AE

Answer is AE

zakupowerOptions: AE

These are correct