Introduction to Displaying Data
Generate random users
The first thing we need is a few users in our database for testing. We could create a database script to do that, but it’s easier to write a simple Java class that can create things in a loop.
Let’s start by creating a
CommandLineRunner implementation. Spring will run any such beans at the startup of the application. By only enabling the bean when the
init-db profile is active, we can toggle if the database should be populated at startup or not.
This is the code for the