From: Kai Moritz Date: Sat, 13 Aug 2022 17:08:49 +0000 (+0200) Subject: Validierung für ApplicationProperties aktiviert X-Git-Tag: rest-producer--json---lvm-2-tage--easy-path~4 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=a9afe8b1db0fa6696c31db72156234caba03ba00;p=demos%2Fkafka%2Ftraining Validierung für ApplicationProperties aktiviert --- diff --git a/pom.xml b/pom.xml index e4d24bb..e7ea677 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,10 @@ spring-boot-configuration-processor true + + org.springframework.boot + spring-boot-starter-validation + org.apache.kafka kafka-clients diff --git a/src/main/java/de/juplo/kafka/ApplicationProperties.java b/src/main/java/de/juplo/kafka/ApplicationProperties.java index 78b6085..673613a 100644 --- a/src/main/java/de/juplo/kafka/ApplicationProperties.java +++ b/src/main/java/de/juplo/kafka/ApplicationProperties.java @@ -4,18 +4,33 @@ import lombok.Getter; import lombok.Setter; import org.springframework.boot.context.properties.ConfigurationProperties; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; + @ConfigurationProperties(prefix = "producer") @Getter @Setter public class ApplicationProperties { + @NotNull + @NotEmpty private String bootstrapServer; + @NotNull + @NotEmpty private String clientId; + @NotNull + @NotEmpty private String topic; private Integer partition; + @NotNull + @NotEmpty private String acks; + @NotNull private Integer batchSize; + @NotNull private Integer lingerMs; + @NotNull + @NotEmpty private String compressionType; }