Hello World microservice example in Java composed of API Gateway, Service, and Lookup (Eureka)

Introduction In this post I’ll run through a very simple Hello World Microservice example (in Java) that covers the main parts of a web type Micro Service. This example composes of: A REST Web Service A Lookup / Discovery system ( I’ve used Eureka ) A type of API Gateway / Web Server Just to … Read more

How to setup a log file in Spring Boot

This is a very short guide to get a log file setup for a Spring Boot Application. Spring uses Logback as its default logging system, and automatically logs to the console. To setup a log file in the resources folder of your app (where application.properties lives ), create a file called logback.xml  (copy / paste … Read more

Maven cheatsheet

Just a place for me to store handy bits and pieces. Having not used it for awhile to remind of things, I’ll likely to forget ! How to compile to different versions of Java ( see also https://mkyong.com/maven/maven-error-invalid-target-release-1-11/ ) <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>11</source> <target>11</target> </configuration> </plugin> In the <build> section How to change the … Read more

Running Docker on AWS

Recently I wanted to use my Java Tomcat Docker image on AWS to run a spring boot app. I looked at the various ways of setting this up ECS (Elastic Container), and found it to be a load of hassle ( for what I needed , I don’t need Kubernetes style functionality , just a … Read more

Threads in Java

We need to control access to shared state ( when multiple threads are at work ), to avoid unexpected results. In the case of the program below the shared state is the int sheepCount. 10 different threads call the method incrementAndReport() . Without thread management  public class Ch18SheepManager { private int sheepCount = 0; private … Read more

How Lambdas can be useful in Java

I’m revising for the OCP (Oracle Certified Professional Java Programmer ), and running over Lambdas at the moment. In tutorials I see many of them seem to focus on what they are , what they do , streams etc. Not much on how they can be used to improve code ( and making less Class … Read more