From 8bc1615e993d85dcab36028dce59911efe7bb64d Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 12 Jul 2020 10:51:41 +0200 Subject: [PATCH] WIP --- .../de/trion/kafka/outbox/Application.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/trion/kafka/outbox/Application.java b/src/main/java/de/trion/kafka/outbox/Application.java index 3e0a723..a5d739c 100644 --- a/src/main/java/de/trion/kafka/outbox/Application.java +++ b/src/main/java/de/trion/kafka/outbox/Application.java @@ -1,19 +1,30 @@ package de.trion.kafka.outbox; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.stereotype.Component; import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @SpringBootApplication @EnableConfigurationProperties(ApplicationProperties.class) -public class Application { +@Component +public class Application implements CommandLineRunner { + + private final static Logger LOG = LoggerFactory.getLogger(Application.class); + @Autowired ApplicationProperties properties; + @Autowired + JdbcTemplate jdbcTemplate; @Bean @@ -42,6 +53,15 @@ public class Application { } + @Override + public void run(String... strings) throws Exception { + + LOG.info("Creating tables"); + jdbcTemplate.execute("DROP TABLE users IF EXISTS"); + jdbcTemplate.execute("CREATE TABLE users(id SERIAL, username VARCHAR(255), loggedIn BOOLEAN)"); + } + + public static void main(String[] args) { SpringApplication.run(Application.class, args); } -- 2.20.1