In this page I will show you how to use gson parse json string to object array. Add gson dependency in pom.xml file.
We can use stream().parallel() to handle tasks in multi-thread. CompletableFuture is very useful when you handle tasks which need to wait IO or network. Let's say you have two services. The one is getting content by contentId and another is getting author information by authorId. Both of them need RPC. In other words, you have to wait the remote server responses. I use Thread.sleep() to mock network delays.
We can use Arrays.asList() to init an array with values. This page will show you how to convert List to T. For example convert List to String. The code is here.
You may have used ThreadPoolExecutor to submit some task and waiting for the result. In this way program can get the better performance. The question is how to calculate the size of pool size, in other words how to make CPU 100% or close to 100% busy?
Stream in Java8 can help us make code clear and efficient. We can use Stream to iterate a collection without the keyword for. It is very convenient. The question is how to print the information of item in a stream? In this page I will show you how to add log in stream. JDK provides peek function for debugging.
In this page I will show you how to integrate MyBatis and Spring. I use maven to build the project. The structure of the project is like following.
We can use show create table to show the create table sql. The best way to export the create table sql is using mysqldump command. Using following command to dump create tables sql of all tables in the test_db database.
There are different ways to generate random 6 digits. I recommend you to use RandomUtils or RandomStringUtils in apache-common-lang3 framework to generate it. Here is the sample code.
Let's say you have a project and there are some module in it. If you want change the version of this project you can find all version number in global search and replace with new version or use following command.
I install Node.js and npm in my virtual machine which OS is CentOS. I following official website here to start my first Angular app. After execute ng new my-app init the project I execute ng serve --open to start the app. The log is here.
Download Node.js Linux Binaries (x86/x64) from here. I use wget to download it.
When I use rm *.log -rf to delete the files I got the following error message.
Use following command to add user name and email.
The default output of git is without color. Add following config in ~/.gitconfig can enable the git color output in your terminal. If there is not .gitconfig file create one.
Collectors.partitioningBy is used to divide stream into two map. The key of two group are true and false. Two list of values are collections of elements that satisfy the condition. The example code is here.