Posts in "Java"

Send emails in Spring Boot

If you are looking for a fast tutorial on how to send emails in Spring Boot applications, then you landed in the right place 😀 1) Add the spring-boot-starter-mail dependency to the pom.xml file <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency> 2) Configure a mail server for testing purposes. I would recommend Mailtrap, a free online service for… Continue reading

Install a Spring Boot Application as a Windows Service

Spring Boot applications are versatile by nature and provide a lot of deployment possibilities. In this post, I am going to show you how to install a Spring Boot application as a Windows service. It is a fairly simple process that should take a couple of minutes 😉 1. Sample Application For this demo, I… Continue reading

Fix Truncation of @PathVariable After Dot in Spring MVC

The Problem Recently, while working on a project I encountered a strange behavior with the path variable binding in Spring controllers. It seems that, by default, the text after the last dot gets truncated in the @PathVariable value. So I decided to share this problem and a solution for it in this post:) Let’s take… Continue reading

Spring Conditional Bean Configuration: Load Beans Based on Custom Conditions

In a previous post, I made a small demo on how to load Java beans based on properties defined in a configuration file. While this is a very common scenario, sometimes you might need to create beans based on completely custom conditions. Once again, Spring provides an elegant solution for this: the @Conditional annotation. The… Continue reading

Spring Conditional Bean Configuration: Load Beans Based on Application Properties File

In complex applications, there are times when you will want the Spring dependency injector to create an instance of a class based on a given condition. One common case is to configure the bean definition based on a property defined in the application.properties file. By using this approach you can load custom beans at runtime… Continue reading

How to deploy Spring Boot applications on Tomcat (as WAR)

By default, Spring-Boot applications are packaged as JAR files and they have an embedded container that hosts them. The embedded container allows developers to not have any web server installed in order to run their apps. This is pretty cool and brings many benefits for developers like easier deployment and management. However, customers usually have… Continue reading

Create a Spring Boot Application Using Multiple Maven Modules

Spring Boot has been receiving a lot of hype lately. There are plenty of materials online. However, most of the examples used to demonstrate Spring Boot are rather simple. In 99% of cases, a single Maven module is used. But, in the real world, developers are building complex applications and they want to structure their… Continue reading