Tag Archives: Spring Boot

Faster Spring Boot startup

As software developers, we always look for opportunities to improve our efficiency at work and optimize repeatable activities. One of them is application startup. Even if you cover your production code with unit tests and follow TDD, from time to time checking how the whole application works is inevitable. The more often you run it, the more time is wasted on waiting until the application is ready to operate. Although the fast restart provided by Spring Boot DevTools is helpful for library class loading, it doesn’t solve the issue with the long startup of your own application code. From this post you will learn how to decrease the total number of coffee breaks in daily work by accelerating the startup of any Spring application in your local development environment.

Continue reading Faster Spring Boot startup


Multiple TTL caches in Spring Boot

Spring Framework provides a comprehensive abstraction for common caching scenarios without coupling to any of supported cache implementations. However, declaration of expiration time for a particular storage is not a part of this abstraction. If we want to set Time To Live of a cache, the configuration of the chosen cache provider must be tuned. From this post you will learn how to prepare setup for several Caffeine caches with different TTL configurations.

Continue reading Multiple TTL caches in Spring Boot


Custom validation annotation in Spring

Although built-in validation support in Spring is largely sufficient for standard use cases, sooner or later every developer runs into a situation when the sets of validation annotations provided by JSR 303 or Hibernate Validator are not enough. In this post you will learn how to create a simple constraint annotation served by a custom validator with access to the Spring context of a Spring Boot application.

Continue reading Custom validation annotation in Spring


Sending HTML mail with Spring Boot and Thymeleaf

Sending an e-mail from the backend application part is a quite common use case in the world of enterprise applications. Although HTML content isn’t standardized message format, numerous mail clients support at least a subset of the markup language. In this post you will learn how to send an e-mail using standard Spring Boot modules and prepare HTML content for a message using Thymeleaf template engine.

Continue reading Sending HTML mail with Spring Boot and Thymeleaf


Spring Boot properties per Maven profile

In the previous post you could read about separate Spring Boot builds for a local development machine and public environments. It’s highly possible that in addition to such setup you would like to load different Spring properties files based on the active Maven profile. In this note you will learn how to accomplish the desired result in a few easy steps.

Continue reading Spring Boot properties per Maven profile


Dual jar/war build for Spring Boot

The great thing about Spring Boot is no need for an external servlet container. All that is needed reside inside a single runnable JAR file. In a very few steps, development of a new application can be started without installation or configuration of any additional software. Yet, sometimes you might want to deploy your application to some server as a regular WAR file. For instance, you convert an existing application and want to keep your continuous delivery pipe untouched or a particular container is enforced by a company’s policy. The reason for building a WAR file may vary across teams, but for development purpose a simple executable JAR file with an embedded server might be preferable.

Continue reading Dual jar/war build for Spring Boot