Micronaut Dependency Injection - The stand-alone Setup

In this post, let's explore how to use Micronaut as the Dependency Injection container in a stand-alone Java application. Let's start by creating a stand-alone Java application. I make use of the initialisers provided by Gradle (gradle init command). The application structure looks as follows. ➜ microdemo tree . ├── build.gradle ├── gradle…

Effective Java with Groovy - Immutability

It would seem like mutability is the default design approach when it comes to Java. However, reading "Effective Java" makes you change your mind. The book suggests - 'minimise mutability'. Also, what is highly useful is the reason for favouring immutability - "immutability is simple". Did you get surprised? Now,…

Java - end of the road for Paths

Java introduced NIO 2 APIs with version 1.7. I wrote an article several years ago, after seeing not many developers make use of the new API. With this API, you would use java.nio.file.Path instead of java.io.File to represent a file. To get an instance…

Micronaut HTTP Client - Error Flow

We have seen Micronaut BlockingHttpClient in action and how to use exchange and retrieve methods to interact with an HTTP endpoint. What happens if your endpoint returns HTTP status code greater than or equal to 400 (they indicate that it's an error)? To explore this, let's create an endpoint that…

Effective Java with Groovy - Favour Internal Iterators

Let's start with the following code making use of the traditional for loop. List<String> languages = List.of("Java", "Groovy", "Kotlin"); // List.of() requires Java 9 or above for (int i = 0; i < languages.size(); i++) { System.out.println(languages.get(i)); } Compare the above code to…

Gradle - running tests in Continuous Build

In a previous post, we saw Gradle's continuous build in action. If you use Test Driven Development at work, you will be running your tests after every code change. Let's leverage Gradle's continuous build so that you don't have to trigger the tests every time you change your code manually.…

Micronaut - Reloading using Gradle's Continuous Build

I have written about my thoughts on hot loading in general in this post. Micronaut from version 1.2 started supporting continuous build, but you had to manually add the configuration entries to your project. With the 2.0 version, Micronaut supports 'continuous build' out of the box. Both Gradle…

Gradle - Continuous Build

Back in 2015, Gradle introduced this feature which they called 'continuous build'. Those days, I was exploring Ratpack, and it was the first toolkit/ framework to leverage the continuous build feature. The idea here is to rerun the tasks whenever there is a code change. Gradle will first run the…