Cache, Spring Boot, Spring Data

Spring cache and integration testing

Using caches in a Spring application is relatively easy. It makes the overall performance better, but opens some exciting problems when it comes to integration testing the application.¬† Adding caching behavior to a functionality without properly thinking over the consequences, is one of the biggest mistakes, a beginner programmer can make. You must have full… Continue reading Spring cache and integration testing

Gradle, Spring Boot

Using Gradle Distribution plug-in

Recently I had to configure the Gradle Distribution plugin for a microservice application, in order to work the same way as the Maven Assembly plugin. This plugin makes it possible to create a tar.gz distribution file for our Spring Boot microservices. It contains the runnable Spring Boot jar file and all necessary configuration files. To… Continue reading Using Gradle Distribution plug-in

Java, Spring, Websocket

Restrict number of connected clients for Websocket

Recently I needed to implement a custom check for WebSocket connection of a Spring Boot application. The logic had to check if a configured connection limit has been reached, and reject opening further connections if so. The connections were opened by a mobile application client, and the developer wanted to get the error message in… Continue reading Restrict number of connected clients for Websocket

REST, Spring

Implementing inheritance for JSON objects

Our App developers wanted to send slightly different JSON elements in a single list, in order to make the App side implementation far less complicated. In order to make it possible to, I decided to implement inheritance hierarchy for the JSON input and the related java DTO classes. The other possibility would be to have… Continue reading Implementing inheritance for JSON objects

Spring, Spring Boot, Spring Data

Tipp and tricks using Spring Data

Spring Data is a very comfortable way of defining DAO objects for your project. It can generate a DAO for your entity class, and provide all basic CRUD functions out of the box. You only need to define an interface, inherited from¬†CrudRepository. For more information of Spring Data basics I recommend reading following resources… Continue reading Tipp and tricks using Spring Data

REST, Spring Boot

Custom validator for REST parameter in Spring Boot

Using Spring boot applications, it is very easy to let the Spring framework to do the validation of the REST input parameter. You only need to add the corresponding validation annotations to the properties of the parameter class, and mark the parameter with @Valid annotation in the method header. @RequestMapping(value = "/register", method = {… Continue reading Custom validator for REST parameter in Spring Boot