X-Git-Url: https://juplo.de/gitweb/?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fde%2Ftrion%2Fkafka%2Foutbox%2FApplication.java;h=f6865f5f6d68e5329d742c535ebf9bfdd5baa7e3;hb=2271c5b01003adc13d5d29afade3c14c85614e1d;hp=a5d739c5a27407613944f095b283fe9f55bcd36e;hpb=8bc1615e993d85dcab36028dce59911efe7bb64d;p=demos%2Fkafka%2Foutbox diff --git a/src/main/java/de/trion/kafka/outbox/Application.java b/src/main/java/de/trion/kafka/outbox/Application.java index a5d739c..f6865f5 100644 --- a/src/main/java/de/trion/kafka/outbox/Application.java +++ b/src/main/java/de/trion/kafka/outbox/Application.java @@ -2,68 +2,16 @@ 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) -@Component -public class Application implements CommandLineRunner { +public class Application { private final static Logger LOG = LoggerFactory.getLogger(Application.class); - @Autowired - ApplicationProperties properties; - @Autowired - JdbcTemplate jdbcTemplate; - - - @Bean - public String bootstrapServers() { return properties.bootstrapServers; } - - @Bean - public String topic() { - return properties.topic; - } - - @Bean - public String consumerGroup() { - return properties.consumerGroup; - } - - @Bean - public WebMvcConfigurer corsConfigurer() { - return new WebMvcConfigurer() { - @Override - public void addCorsMappings(CorsRegistry registry) { - registry - .addMapping("/**") - .allowedOrigins("http://localhost:4200"); - } - }; - } - - - @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); } - }