How can I put initial data in DB after initiating Spring Boot?
I would like to do like this:
- If
database
already exists, nothing happens. - After automatically a database created, which has many tables described in entity files,
I would like to put initial data by certain method like this:
@Autowire
UserRepository ur;
public void putdata(){
User u = new User();
ur.save(u);
}
The important point is #1 above. When database already exists, the method must not be called and not using a SQL file outside.