Dockerize Your Spring Boot Projects Using Dockerfile or Maven

Photo by Karine Germain on Unsplash

Since I implemented my project using Java 16, I will base my image with “openjdk:16-jdk-alpine”.

Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.

You can find here a list of instructions (both valid and deprecated) here.

Create a Dockerfile in your project’s main folder (where your pom.xml resides) and update content below according to your own project:

Firstly, you need to have…

How to Commit to a Different Project with a Different Username and Credentials

Photo by Andrew Neel on Unsplash

After creating a new project in GitHub (I prefer to create via GitHub web page), you can run these commands:

“config” commands can also take parameter “global” but here we intend to change our settings just for this local commit.

As of August 2021, you cannot run the latter command…

Use Spring Cloud Bus and Spring Cloud Config Server Together

Photo by Yehor Litsov on Unsplash

Firstly, you can follow these instructions for Spring Cloud Server:

Add these to your dependencies as an extra for Spring Cloud Bus:

If you would like to inspect which dependencies in “spring-cloud-starter-bus-kafka”, these are the dependencies in version 3.0.3 (Here, I use a plugin called Maven Helper in IntelliJ to use “Dependency Analyzer” view in pom.xml file).

How to enable auto restart with Spring Developer Tools in Intellij

Photo by Daniel on Unsplash

Applications that use spring-boot-devtools automatically restart whenever files on the classpath change.

You might have to do these additional steps if you are using IntelliJ as your IDe and your project does not auto-refresh although you have added Spring Boot Developer Tools dependency (spring-boot-dev tools) in your project.

Go to IntelliJ IDEA / Preferences / Advanced Settings.
Check “Allow auto-make to start even if the developed application is currently running” under the “Compiler” section.

Add a Circuit Breaker to Your Feign Client

Photo by Aaron Burden on Unsplash

What happens if the service is not available rather than having exceptions for a REST API call?

Integrate Sleuth and Zipkin to your Spring Boot Microservices for distributed logging

Photo by Pietro De Grandi on Unsplash

You can visit here for more details, these bullets are from the same link:

Transparently create and inject a correlation ID into your service calls if one doesn’t exist.

Manage the propagation of the correlation ID to outbound service calls so that the correlation ID for a transaction is automatically added to outbound calls.

Add the correlation information to Spring’s MDC logging so that the generated correlation ID is automatically logged by Spring Boots default SL4J and Logback implementation.

Optionally, publish the tracing information in the service call…

Spring Cloud Config Server Development

Photo by sendi gibran on Unsplash

There are many sites and posts about the details of development with Spring Boot and Spring Cloud but this post will be just about implementation and some notes about what I did and why I did it that way.

If you do not want to use git but a local path for properties file location, you should add “native” to your spring profiles in your config server project:

So this is my final file for my config server project:

What makes a project a config “server” is this dependency:

Create Different Profiles in Maven pom.xml

Photo by Pete Godfrey on Unsplash

For my Java project’s obfuscation, I used Zelix as I described in this post.

Later on, while the project continues to evolve, to be able to understand exceptions, logs, etc. better in test environment, I wanted to be able to obfuscate or not based on a config in my pom.xml.

Following this link, I was able to accomplish it by “profiles”:

You can now run “mvn package” command with your profile parameter:

“activeByDefault” in pom.xml is used for default configuration where you do not send a profile parameter in your command.

Happy Coding!

Photo by yeoul Shin on Unsplash

After upgrading Zimbra version to the newest, I started getting NoClassDefFoundError for slf4j dependency in Sentry on start up.

Configure Path Aliases in Angular Library Project

Photo by Steve Adams on Unsplash

I had written about how to define typescript aliases in your Angular project here:

When you are working with a library project, things differ since now you will be working in a multi module project.

First of all, you will encounter into a tsconfig file problem if you are using Visual Studio Code:

VsCode automatically looks for a tsconfig.json file and it doesn't care about, so paths needs to be specified in tsconfig.json.

For that reason, we will be editing our tsconfig.json file in the project’s main folder. Since we will have…

Señorita Developer

I would love to change the world, but they won’t give me the source code | coding 👩🏼‍💻 | coffee ☕️ | jazz 🎷 | anime 🐲 | books 📚 | drawing 🎨

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store