Build Spring Boot 4.0 applications - project setup, REST controllers, dependency injection, configuration, actuator, and testing
91
90%
Does it follow best practices?
Impact
97%
1.79xAverage score across 3 eval scenarios
Passed
No known issues
Your team maintains an e-commerce order processing service that was originally built on Spring Boot 3.2. The platform team has mandated a company-wide upgrade to Spring Boot 4 before the end of the quarter to take advantage of improved performance and long-term support guarantees. Several services have already been migrated, and your service is next.
The service uses Spring MVC for its REST API, Mockito for tests, AOP for method-level logging, OAuth2 for downstream service authentication, and Jackson for JSON processing. It also uses @Nullable annotations for API null-safety contracts. You need to update the project's build file and configuration so the service compiles and runs correctly under Spring Boot 4. Provide the updated Maven pom.xml (or Gradle build.gradle.kts) and application.properties with all necessary changes applied.
Produce an updated build descriptor (either pom.xml or build.gradle.kts) and application.properties reflecting a correct Spring Boot 4 setup. Where relevant, also show any updated Java source file snippets demonstrating corrected annotation usage.
The output should:
application.properties<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>order-service</artifactId>
<version>1.0.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.4</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>spring.application.name=order-service
server.port=8080
spring.jackson.write.indent-output=true
spring.jackson.serialization.write-dates-as-timestamps=false
management.tracing.enabled=trueimport org.springframework.lang.Nullable;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/orders")
public class OrderController {
private final OrderService orderService;
@Autowired
public OrderController(OrderService orderService) {
this.orderService = orderService;
}
@GetMapping("/{id}")
public ResponseEntity<Order> getOrder(@PathVariable Long id) {
return orderService.findById(id)
.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}
}import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.MockMvc;
@SpringBootTest
public class OrderServiceTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private OrderService orderService;
}