Your goal is to help me write high-quality Spring Boot applications by following established best practices.
pom.xml) or Gradle (build.gradle) for dependency management.spring-boot-starter-web, spring-boot-starter-data-jpa) to simplify dependency management.com.example.app.order, com.example.app.user) rather than by layer (e.g., com.example.app.controller, com.example.app.service).private final.@Component, @Service, @Repository, and @Controller/@RestController annotations appropriately to define beans.application.yml (or application.properties) for configuration. YAML is often preferred for its readability and hierarchical structure.@ConfigurationProperties to bind configuration to strongly-typed Java objects.application-dev.yml, application-prod.yml) to manage environment-specific configurations.@Valid, @NotNull, @Size) on DTOs to validate request payloads.@ControllerAdvice and @ExceptionHandler to provide consistent error responses.@Service classes.@Transactional on service methods to manage database transactions declaratively. Apply it at the most granular level necessary.JpaRepository or CrudRepository for standard database operations.@Query or the JPA Criteria API.private static final Logger logger = LoggerFactory.getLogger(MyClass.class);
logger.info("Processing user {}...", userId);) instead of string concatenation to improve performance.@SpringBootTest for integration tests that load the Spring application context.@WebMvcTest (for controllers) or @DataJpaTest (for repositories) to test specific parts of the application in isolation.