Spring profiles with Maven
How to set Spring active profiles with maven profiles? In this example we will setup configuration for Spring Boot profile activated by Maven.
How to set Spring active profiles with maven profiles? In this example we will setup configuration for Spring Boot profile activated by Maven.
Today we will learn how to configure PostgreSQL with docker for Spring Boot application. At the end of this article you should have Spring Boot application running on Tomcat server connected via JNDI to PostgreSQL data source. (more…)
Static utility classes are common in libraries and in user code. For example Java Math for basic mathematical calculations or DateUtils to operate on Date/LocalDate objects. It’s not always wrong to create and use them but sometimes using utility methods are considered code smell. I’ll try to explain when and why use or not to use such methods. This article is not only for Java language. Rules presented here can be universal in other OOPs(Object Oriented Languages) having similar mechanisms to Java statics.
(more…)
Java mind map is useful tool when you want to learn Java from scratch. Or if you are already experienced developer and you want to refresh your knowledge. Below you see a full Java mind map with general topics. It is based on Oracle documentation and some interview questions.
I decided to share this mind map, cause I’ve searched for good Java mind map and found only general ones. So, if you preparing for an interview or learn from scratch, it’s perfect starting point 😉 (more…)
Recently I started new project in which I needed to use Java modules. So I set up a maven project with Java 10 and pulled jboss/wildfly docker image. Unfortunately it turned out that official jboss image does not support JDK 9/10, probably because of new Oracle license. But I don’t know why they do not …
In last few years “microservices” term was very popular and almost everyone wanted to migrate their systems to such architecture. But what’s wrong with monolithic applications you may ask. Actually nothing. Monolith apps are as good as microservice apps. It’s not the case what is better. I don’t want to discuss what are the benefits …
I named it command-handler pattern, but actually it’s modified command pattern. In classic command pattern, we have Command class that handles action on a given object. You can see it in Switch example. First difference is decoupling of command and action execution. It also simplifies segregating read and write queries/commands (aka. CQRS). In command handler pattern, commands …
In this article I will present simple yet effective best practice for making code more readable by changing method arguments. It’s a good practice to only pass values, that the method requires, everything else ruins readability and causes tests to be more complicated. Following this simple rule we will check how it really affects code quality. We will start with example code of tax calculation, then we will try to refactor it to be more readable and testable. Note that the example is exaggerated and of course can be simplified but it visualizes the problem. Real world cases will be more complicated than that, so you can imagine how this little change can influence things.
In this article we will quickly install Oracle Java JDK 10 on Ubuntu 17.10 machine from terminal. There are multiple methods of doing it, some more easy and some more sophisticated, like using bash scripts. It always depends on use case, but we will do it as simple as it can be. For this moment Java 10 and Ubuntu 17.10 are fresh versions so you may find it useful like I did.
Mocking time in Java 8 can be tricky.
At first take a look at use case scenario, it’s obvious but it’s a good starting point. First solution is to pass Clock instance as method parameter.
Second solution is to inject it as private field. The last solution does not need any fancy frameworks so you can use it on core Java.