How do you implement profiles in Spring Boot applications?
A worked example of Spring Boot profiles: H2 for development, MySQL for production, profile-specific beans, activation options and testing.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
A worked example of Spring Boot profiles: H2 for development, MySQL for production, profile-specific beans, activation options and testing.
Use application.yml for defaults, profile files per environment, environment variables for secrets and typed @ConfigurationProperties classes, and know the precedence order.
MessageSource separates translated text from code and resolves it by key and locale. Learn its lookup order, setup and practical i18n tips.
Implement LocaleResolver, register it as a bean named localeResolver, and resolve the locale from a header, user profile or tenant in Spring Boot 3.
@RequestMapping only routes requests; locale comes from a LocaleResolver. Learn how to switch language, load message bundles and map locale in the URL.
Spring Boot auto-configures message sources, so i18n needs properties files and a locale resolver. Setup with Thymeleaf and cookie-based switching.
@ModelAttribute binds form and query parameters to Java objects and shares model data with views in Spring MVC. See examples, validation and common pitfalls.
Bind a form with th:object, validate it with @Valid and BindingResult, show field errors in Thymeleaf and redirect after a successful submit.
ThymeleafViewResolver turns controller view names into rendered Thymeleaf templates. See how Spring Boot configures it and how to set it up by hand.
Add the Thymeleaf starter, return view names from controllers, and build pages with loops, fragments and validated forms in Spring Boot.
Configure Spring MVC view resolvers for JSP, Thymeleaf and FreeMarker with Java config or Spring Boot properties, and order several resolvers correctly.
The old spring.resources.static-locations property is now spring.web.resources.static-locations. Learn the default folders, custom locations and caching.
Spring Boot serves files from /static, /public and /resources by default. Learn to customise locations, cache headers, versioning and security.
InputStreamResource streams data from an InputStream to the response without buffering the whole file. See headers, path safety, limits and when to use other resources.
@RequestPart binds a single multipart part, so a JSON object and a file can arrive in one Spring request. Learn usage, validation and pitfalls.
Upload files in Spring Boot 3 using MultipartFile and transferTo, set size limits, store under safe names, handle errors and test with MockMvc.
Build search endpoints in Spring Boot with Spring Data JPA, dynamic Specification filters and pagination, plus full-text options.
@RequestParam binds query, form and multipart values to controller method parameters. Learn its attributes, defaults, conversion and error handling.
Read, bind and validate query parameters in Spring MVC with @RequestParam, @ModelAttribute records, defaults, converters and clear 400 errors.
Dynamic filtering in Spring Data JPA uses the Criteria API through Specification. See how to build reusable filters with paging and sorting.