Free 2V0-72-22 sample questions

Real questions from the 2v0-72.22 practice bank, with the correct answer and an explanation for each one. No junk, no filler.

Try them in the simulator Same questions, with study, timed and flashcard modes.

Showing 10 of 20 free sample questions.

Question 1Choose one

A financial application needs to perform a complex operation involving two separate database updates. The outer service method, `transferFunds()`, is annotated with `@Transactional(propagation = Propagation.REQUIRED)`. It calls an inner service method, `logAudit()`, which must commit its record regardless of whether the `transferFunds` operation succeeds or fails. Which propagation level should be applied to the `logAudit()` method to achieve this behavior?

Question 2Choose 2

A developer needs to configure a Spring Security setup for a REST API. The requirement is to allow unauthenticated access to `/api/public/**` endpoints, while all other endpoints under `/api/**` must be authenticated. Which two of the following `HttpSecurity` configurations correctly implement this requirement? (Select TWO)

Question 3Choose one

When writing a slice test for a Spring Data JPA repository using `@DataJpaTest`, the test transaction will, by default, roll back at the end of each test method.

Question 4Choose one

A Spring Boot application needs to connect to a database whose credentials are provided via environment variables `DB_URL`, `DB_USER`, and `DB_PASS`. The `application.properties` file contains the following entries: `spring.datasource.url=${DB_URL:jdbc:h2:mem:defaultdb}` `spring.datasource.username=${DB_USER:sa}` `spring.datasource.password=${DB_PASS:}` If the `DB_USER` environment variable is NOT set, but `DB_URL` and `DB_PASS` are, what value will be used for the datasource username?

Question 5Choose one

An architect is designing a REST API using Spring MVC. The API needs to return different JSON representations of a `User` object depending on the endpoint. For example, `/api/users/{id}` should return all user fields, but `/api/users/summary` should return only the `id` and `username`. What is the most appropriate Spring feature to implement this requirement without creating separate DTOs (Data Transfer Objects) for each view?

Question 6Choose one

A developer needs to create a Spring bean that calculates a value based on other beans, but this calculation only needs to happen once at startup. The result should then be cached and injected into other components. Which combination of annotations and lifecycle callbacks is most suitable for this scenario?

Question 7Choose one

A Spring Boot application uses a `JdbcTemplate` to perform database queries. During a code review, a senior developer points out a potential SQL injection vulnerability in the following code snippet: `String status = "ACTIVE";` `String sql = "SELECT * FROM users WHERE status = '" + status + "'";` `jdbcTemplate.query(sql, userRowMapper);` What is the best way to refactor this code to prevent the SQL injection vulnerability?

Question 8Choose one

**Company Background** A large e-commerce company, "ShopFast", is modernizing its monolithic backend. They are adopting a microservices architecture and have chosen Spring Boot for new services. One of the first services being built is the `OrderProcessingService`. This service needs to be highly available and observable. **Current Situation** The development team has built the core logic for the `OrderProcessingService`. It exposes several REST endpoints for creating and querying orders. The service interacts with a PostgreSQL database and a RabbitMQ message queue. The company has a centralized Prometheus server for metrics collection and Grafana for dashboarding. The security team mandates that all management endpoints must be secured and only accessible by administrators. **Requirements** 1. The service must expose its operational status, including database connectivity and message queue health. 2. Key business metrics, such as `orders_created` and `order_processing_time`, must be exposed in a format compatible with Prometheus. 3. All management and monitoring endpoints must be exposed on a separate port from the main application port (8080) for security reasons. 4. Access to these management endpoints must be restricted to users with the `ADMIN` role. **Question** Which set of configurations in `application.properties` and dependencies in `pom.xml` will satisfy all the stated requirements?

Question 9Choose one

A developer is using Spring Expression Language (SpEL) to conditionally create a bean. The goal is to create the `EmailService` bean only if the application profile is 'production' AND a system property named 'email.enabled' is set to 'true'. Which `@ConditionalOnExpression` annotation is correct?

Question 10Choose one

A developer wants to implement method-level security on a service method. The requirement is that only users who have the role 'ADMIN' OR are the owner of the account can invoke the `getAccountDetails` method. The method signature is `getAccountDetails(String username)`. How should the `@PreAuthorize` annotation be written to enforce this rule?

10 more free samples are waiting

Create a free account to unlock the whole 2V0-72-22 sample bank, or get full access to all 192 practice questions in the simulator.

Create account