Java serialization when object changed

It is easy to serialize object to byte array and deserialize byte array to object. Today I will show you how to serialize and deserialize object when it changed.

Spring Boot interceptor example

In this page I will show you how to use interceptor in Spring Boot. You can use interceptor handling common business logic. The structure of project is like following.

MySQL enable remote access

In this page I will show you how to make MySQL to support remote accessing. I assume you install MySQL in your environment and local login successfully. Before remote accessing we need creating a database.

Your password does not satisfy the current policy requirements

When you see "Your password does not satisfy the current policy requirements" error message that means your password is not safe. MySQL use validate_password plugin to test passwords and improve security. There are 3 levels in validate_password_policy. You can check the value of it by using following command.

First time login MySQL after installation

In last blog I have introduced how to install MySQL in CentOS. In this page I will show you how to login MySQL for the first time.

Install MySQL in CentOS

In this page I will show you how to install MySQL in CentOS. My environment is CenOS6, it is almost same steps to install MySQL in other version of CentOS. We assume that you have install CentOS successfully.

Mybatis generator maven example

I have wrote a tutorial how to generator Mybatis entity and mapper by using idea Mybatis plugin. In this blog I will how you how to generator Mybatis entity and mapper by using maven plugin. Before using IDEA plugin you need pay for it, maven plugin is free instead.

Convert windows path to unix in java

File separator is "/" on UNIX and "\" on Windows. Using FilenameUtils convert path between windows and UNIX is easily. FilenameUtils.separatorsToSystem method can help you to use correct separator.

Jackson convert json to generic object example

It is easy using Jackson to convert JSON string to Object. In this page I will show you how to convert JSON string to generic object with Jackson. TypeReference is very useful when you convert json string to generic object (like Map, List or other generic object).

Calculate time ago in java

The code below shows how to calculate relative time. Invoke getRelativeTime method by passing a timestamp.

Jackson ignore unrecognized field

You will get UnrecognizedPropertyException if you convert json string to object with unknown field. There are 2 ways to avoid this problem. Use JsonIgnoreProperties annotation or add DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES to ObjectMapper configuration. Examples are in the following.

Jackson convert object to pretty json

We use Jackson convert object to json string. If you do not add any configuration the string is plain-text without formatted. There are 2 ways to make the json pretty when using Jackson convert object to json.

Different garbage collectors in java

In this page we will go through different garbage collectors in java. I have introduced the algorithms of garbage collection in last blog. There are 7 garbage collections in hotspot virtual machine.

Algorithm of garbage collection in java

There are several garbage collectors in java. If your program is small you do not need change the default collector in virtual machine. But if your program become bigger and bigger you need think about change the JVM arguments or even change the collector of virtual machine to make it run efficiently. In this blog I will introduce the algorithm of them. In general, there are 4 algorithms to garbage collection.

Markdown quotes

It is easy to use markdown write formatted text. If you want add quotes in your text you can add > before the line. Examples like following.