Spring utilities and extension points
19 questions in 6 subtopics.
ResourceLoader and Resource
What is the difference between classpath: and classpath*: in Spring resource locations, and when do you need the second one?Code that callsnew ClassPathResource("templates/report.txt").getFile() works in the IDE but throws FileNotFoundException when the app runs from the Boot jar. Why, and how do you fix it?Templates, reports and reference files are loaded from the classpath, the file system and HTTP URLs in different services, and a missing file once broke production. How would you standardise resource loading?Type conversion and formatters
A request parameter like ?range=2024-01-01..2024-02-01 should bind to aDateRange object in a controller. Show how you would register this conversion.Explain how ConversionService, Converter, GenericConverter, Formatter and PropertyEditor relate, and which one Spring uses for @Value, MVC binding and configuration properties.Type conversion and formatting rules for money, dates and identifiers differ across your services and cause data errors between systems. How would you set long-term standards for value types?MessageSource and i18n
Configure a Spring Boot application to return validation messages in English and German, with filesmessages.properties and messages_de.properties, based on the Accept-Language header. What do you need?A product is going to 12 locales across 20 services. How would you organise message bundles, error messages and translation workflow so that services stay consistent?Your product will expand to many countries over the next years. What would you decide now about internationalisation in Spring services to avoid expensive changes later?@Async and task execution
A method annotated with@Async runs on the caller thread instead of a pool thread. List the common causes.An @Async method needs the caller's MDC trace id and security context. Show how you would carry them across the thread hop.An @Async method that sends notifications causes memory to grow during traffic spikes until the service runs out of heap. Boot's default task executor is in use. What is happening and how do you fix it?Each service defines its own thread pools for @Async, scheduling and HTTP clients, with very different sizes. What would a platform standard for task execution look like?Spring Retry
Write a method that retries a call to a payment gateway up to 3 times with exponential backoff using Spring Retry, and returns a fallback when all attempts fail.A service retries failed downstream calls 5 times on every layer: the HTTP client, a@Retryable service method and the caller's own loop. During a downstream outage traffic to it grows sharply. What is going on and what policy would you set?Utilities such as Spring Retry, @Async executors and resource loading are often copied between services with small differences. How do you decide what the platform should own and what teams should own?Sending email with JavaMailSender
Configure Spring Boot to send an HTML email with an attachment usingJavaMailSender and MimeMessageHelper. Which properties do you set, and how do you test it without a real SMTP server?Order confirmation emails are sent with JavaMailSender inside a @Transactional method that saves the order. Customers sometimes get emails for orders that were rolled back, and SMTP slowness makes checkout slow. Redesign it.Many Spring Boot services each send email with their own JavaMailSender configuration, templates and SMTP credentials. A credential leak led to spam sent from your domain. What do you change?No question matches these choices.