Spring Boot Thymeleaf example

Thymeleaf is a Java template engine. In this page I will show you how to use it in Spring Boot. You can use it to display the page. The structure of project is like following.

Spring Boot exception handler example

In this page I will show you how to use ExceptionHandler annotation handle exceptions. The structure of project is like following.

Linux combine files into one

We use cat command to combine multiple files into one. Here are the examples. Let's say you have 3 files like following.

Jackson convert json to pretty json

I have showed you how to convert object to pretty json in my previous blog. Today I will how you how to convert json string to pretty json. Before using writerWithDefaultPrettyPrinter method we need to convert json string to Object first then convert object to pretty json.

Java remove all null elements from list

If there are more than one null elements in list list.remove() method can not remove all of them. Use list.removeAll() to remove them. Example code is like following.

Could not locate executable winutils.exe

Today I got the error message like following.

Java visitor pattern example

The visitor is the most complex design pattern. This pattern shows us how to "visit" the elements of one structure without changing the code of element's. Add a new visitor when you want to add a new operation for these elements.

Java BigDecimal example

In Java do not use float or double to do decimal arithmetic. Use BigDecimal instead of float and double. If you want to know the details click here.

CentOS remove press any key to enter the menu

After fresh installing CentOS and starting the system there is a sentence on the screen "Press any key to enter the menu, Booting boot in __seconds". Editing the /etc/grub.conf to remove the sentence and start CentOS quickly. The content is like following.

Enable network after centos minimal install

The network is disabled after minimal install CentOS. You can use the following command to enable the network. service network start. The network service does not start after rebooting the system. Change the config file to make the network automatic start. The path of configuration file is /etc/sysconfig/network-scripts/ifcfg-eth0. The content of configuration file is like following.

Linux alias command permanent

The command alias helps us us short command instead of long command and parameters. The problem is when you next time login the shortcut is disappeared. You need to change the .bashrc file to define your specific aliases. The path of .bashrc is ~/.bashrc. For example, you want us vim instead of vi command. Edit your .bashrc file like following.

Linux often-used commands tutorial

This page will show you often-used commands in Linux.

Linux alias command example

alias can help you make long command as a shortcut. For example, you have to type mysql -h host_address -u user_name -p when you need access mysql remotely. alias can make this efficiently. Create a shortcut for remote accessing by using the command below. Next time when you want to access database just type mysql-remote.

Virtualbox install Linux unable to boot

After creating virtual machine I want to install CentOS6 (32bit). I got the error message like following.

Jackson JsonMappingException: Object is null

When I try to convert net.sf.json.JSONObject to json I got the JsonMappingException. After checking the stack information I know I forget init the value of user. The detail of exception is like following.