So, I needed a distributed lock on the GCP Datastore. In theory, it is all very simple: Get the lock Do what you need to do Release the lock And, when I started thinking about it, it became clear that I need to have some kind of transaction mechanism in order to obtain the lock….
Category: Spring Boot
Spring Integration Testing – WireMock and MQ
When writing integration tests for parts of the application that talk to other applications, for example calling REST APIs or sending JMS messages, sometimes we just want to test the application and not do end to end test. In this case, we would need to mock these other applications or their behavior. Mocking REST For…
Multiple projects inside one IntelliJ instance
When you are working with multiple projects, for example a number of microservices, it becomes problematic to have an IntelliJ instance open for each of those. There is a trick that allows us to have multiple projects open inside one IntelliJ instance (this saves time, space and RAM :)). Basics steps are as follows: Create…
MapStruct
When working with Spring services and exposing REST API calls, you would usually want to have a set of customized objects exposed to the outside world. These objects, usually called DTOs, can expose some of the domain objects or some projection made out of domain objects (or something else). For mapping between domain data objects…
SpringBoot, Axon, Multiple Data Sources = ? are you doin’?
Ok, so, after playing with this for few days, I have decided to put this into a form of a post, to serve mostly as a reference for anyone facing the same or similar problem. After all, how do you think I solve my problems? Just like that, I search online for solution, then for…
Run SpringBoot app inside alpine docker container
Build the image: docker build -t alpine-java-3 . Run the image, map the ports 8080 to host machine: docker run -d -p 8080:8080 alpine-java-3
Maven/Gradle – exclude tests
Excldue tests in Maven, example: Maven documentation. Exclude tests in Gradle, example: Gradle documentation.
Spring external .properties file
Before we proceed, be sure the check out the spring-cloud-config. Depending on your use case, this might be what you want , Spring Cloud Config. Lets say that we have following .properties files in our project: application.properties application-dev.properties application-prod.properties custom.properties Spring will use these files, if we do not tell it otherwise. We can override…
Remote debugging Spring Boot App
I have an application running on a remote server and I need to debug it. Don’t worry, server is firewall-ed and access is strictly controlled. What we want to achieve is to run the spring boot application in debug mode. We need to tell the VM to run in debug, how we will connect to…
Run SpringBoot application in Docker image
This is a short recipe on how to run your spring boot application within a docker image. The idea comes from John Thompson’s docker for java developer course, so be sure to check it out here https://www.udemy.com/docker-for-java-developers/. What do we want to accomplish? Create a fat (uber) jar of our application Create a Docker file…