How can you enable transaction management in a Spring Boot application?
- By annotating methods or classes with @Transactional.
- By configuring transactions in the application.properties file.
- By using the @EnableTransactionManagement annotation.
- Spring Boot enables transaction management by default.
You can enable transaction management in a Spring Boot application by using the @EnableTransactionManagement annotation. This annotation tells Spring to enable transactional behavior for annotated methods. While you can also annotate methods or classes with @Transactional to specify transactional behavior, you need to enable transaction management globally with @EnableTransactionManagement. Spring Boot does not enable transaction management by default, and configuring transactions in application.properties is not a common approach for enabling transaction management.
Loading...
Related Quiz
- You are assigned to implement Two-Factor Authentication in a Spring Security application. How would you approach this task, considering Spring Security configurations and components?
- The @WebMvcTest annotation in Spring Boot will _____ any @Component, @Service, and @Repository beans by default.
- How does the @Controller annotation interact with the view in a traditional Spring MVC application?
- In a Spring application with multiple security configurations, how would you ensure that the security annotations on service methods are evaluated in the correct order to enforce the intended security constraints?
- The _____ annotation in Spring Boot is used to provide global exception handling across all @Controller classes.