2V0-72.22 Practice Test practice questions, page 4 of 4, with answer review and explanations.
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.)
@ConditionalOnBean(name= “dataSource”) should be replaced with @ConditionalOnBean (DataSource.class) for greater flexibility.
@ConditionalOnBean(name= “dataSource”) should be replaced with @ConditionalOnMissingBean (DataSource.class) for greater flexibility.
The @Bean annotation should be removed.
A JdbcTemplate bean will be created when the DataSource class is in the classpath but there is no DataSource bean.
A JdbcTemplate bean will be created when a bean named dataSource has already been created.
Question 17
What is a Spring Boot starter dependency? (Choose the best answer.)
A setting for specifying which code you want Spring Boot to generate for you.
A specific POM which you must build to control Spring Boot’s opinionated runtime.
A pre-existing model project you can download and use as the basis of your project.
An easy way to include multiple, coordinated dependencies related to a specific technology, like web or JDBC.
Question 18
Which two are required to use transactions in Spring? (Choose two.)
Add @EnableTransactionManagement to a Java configuration class.
Annotate a class, an interface, or individual methods requiring a transaction with the @Transactional annotation.
A class must be annotated with @Service and @Transaction.
A class requiring a transaction must implement the TransactionInterceptor interface.
Write a Spring AOP advice to implement transactional behavior.