From 68d951b20012882c0584dfa1179c0488a4f054b6 Mon Sep 17 00:00:00 2001 From: Kai Moritz Date: Sun, 18 Sep 2022 14:44:35 +0200 Subject: [PATCH] Implementierung vereinfacht & an Spring-Beispiele angepasst --- src/main/java/de/juplo/kafka/Application.java | 22 ++++++++++++++ .../juplo/kafka/ApplicationConfiguration.java | 29 ------------------- 2 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 src/main/java/de/juplo/kafka/ApplicationConfiguration.java diff --git a/src/main/java/de/juplo/kafka/Application.java b/src/main/java/de/juplo/kafka/Application.java index 0069257..b2f0817 100644 --- a/src/main/java/de/juplo/kafka/Application.java +++ b/src/main/java/de/juplo/kafka/Application.java @@ -2,11 +2,33 @@ package de.juplo.kafka; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.kafka.KafkaProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.kafka.annotation.EnableKafka; +import org.springframework.kafka.core.KafkaTemplate; @SpringBootApplication +@EnableConfigurationProperties({ KafkaProperties.class, ApplicationProperties.class }) +@EnableKafka public class Application { + @Bean + public RestGateway restGateway( + ApplicationProperties applicationProperties, + KafkaProperties kafkaProperties, + KafkaTemplate kafkaTemplate) + { + return + new RestGateway( + kafkaProperties.getClientId(), + applicationProperties.getTopic(), + applicationProperties.getPartition(), + kafkaTemplate); + } + + public static void main(String[] args) { SpringApplication.run(Application.class, args); diff --git a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java b/src/main/java/de/juplo/kafka/ApplicationConfiguration.java deleted file mode 100644 index 59652c0..0000000 --- a/src/main/java/de/juplo/kafka/ApplicationConfiguration.java +++ /dev/null @@ -1,29 +0,0 @@ -package de.juplo.kafka; - -import org.springframework.boot.autoconfigure.kafka.KafkaProperties; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.kafka.annotation.EnableKafka; -import org.springframework.kafka.core.KafkaTemplate; - - -@Configuration -@EnableConfigurationProperties({ KafkaProperties.class, ApplicationProperties.class }) -@EnableKafka -public class ApplicationConfiguration -{ - @Bean - public RestGateway restGateway( - ApplicationProperties applicationProperties, - KafkaProperties kafkaProperties, - KafkaTemplate kafkaTemplate) - { - return - new RestGateway( - kafkaProperties.getClientId(), - applicationProperties.getTopic(), - applicationProperties.getPartition(), - kafkaTemplate); - } -} -- 2.20.1