Validierung für ApplicationProperties aktiviert
authorKai Moritz <kai@juplo.de>
Sat, 13 Aug 2022 17:08:49 +0000 (19:08 +0200)
committerKai Moritz <kai@juplo.de>
Sat, 13 Aug 2022 17:08:49 +0000 (19:08 +0200)
pom.xml
src/main/java/de/juplo/kafka/ApplicationProperties.java

diff --git a/pom.xml b/pom.xml
index e4d24bb..e7ea677 100644 (file)
--- a/pom.xml
+++ b/pom.xml
       <artifactId>spring-boot-configuration-processor</artifactId>
       <optional>true</optional>
     </dependency>
+    <dependency>
+      <groupId>org.springframework.boot</groupId>
+      <artifactId>spring-boot-starter-validation</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.kafka</groupId>
       <artifactId>kafka-clients</artifactId>
index c74f588..673613a 100644 (file)
@@ -4,17 +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;
 }