@@ -0,0 +1,1170 @@
+package hello.config.data;%0A%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.context.ApplicationListener;%0Aimport org.springframework.context.annotation.Profile;%0Aimport org.springframework.context.event.ContextRefreshedEvent;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport hello.models.Greeting;%0Aimport hello.services.GreetingService;%0A%0A@Component%0A@Profile(%7B %22default%22, %22test%22 %7D)%0Apublic class InitialDataLoader implements ApplicationListener%3CContextRefreshedEvent%3E %7B%0A%0A%09private final static Logger log = LoggerFactory.getLogger(InitialDataLoader.class);%0A%0A%09private final static String GREETING = %22Hello, %25s!%22;%0A%0A%09@Autowired%0A%09private GreetingService greetingService;%0A%0A%0A%09@Override%0A%09public void onApplicationEvent(ContextRefreshedEvent event) %7B%0A%0A%09%09if (greetingService.count() %3E 0) %7B%0A%09%09%09log.info(%22Database already populated. Skipping data initialization.%22);%0A%09%09%09return;%0A%09%09%7D%0A%0A%09%09Greeting greeting = new Greeting();%0A%09%09greeting.setTemplate(GREETING);%0A%0A%09%09greetingService.save(greeting);%0A%0A%09%09log.info(%22Added greeting (%22 + greeting.getId() + %22): %22 + greeting.getTemplate());%0A%09%7D%0A%7D%0A

Add an initial data loader class for default/test.