From: Kai Moritz Date: Sat, 13 Aug 2022 17:08:49 +0000 (+0200) Subject: Validierung für ApplicationProperties aktiviert X-Git-Tag: rest-producer--explicit-partitioning~2 X-Git-Url: http://juplo.de/gitweb/?a=commitdiff_plain;h=ea7d97d77f8abf272006c79ed6307eef0f74b6b5;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; }