From 6ad4986f913ecd5d7f7b557f02f4b82ecb29d822 Mon Sep 17 00:00:00 2001 From: Dennis van Loon <> Date: Wed, 26 Oct 2022 20:12:49 +0200 Subject: [PATCH] add property from configmap --- pom.xml | 14 +++++++++++++- .../dvl/adobesign/config/AdobeSignConfig.java | 16 ++++++++++++++++ .../adobesign/controller/ContactController.java | 7 ++++++- src/main/resources/templates/index.ftlh | 1 + 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/dvl/adobesign/config/AdobeSignConfig.java diff --git a/pom.xml b/pom.xml index 30546a6..76550b9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.boot spring-boot-starter-parent - 2.7.4 + 2.7.5 com.dvl @@ -29,6 +29,18 @@ org.springframework.boot spring-boot-starter-data-jpa + + + org.springframework.cloud + spring-cloud-context + 3.1.4 + + + org.springframework.cloud + spring-cloud-kubernetes-commons + 2.1.4 + + commons-fileupload commons-fileupload diff --git a/src/main/java/com/dvl/adobesign/config/AdobeSignConfig.java b/src/main/java/com/dvl/adobesign/config/AdobeSignConfig.java new file mode 100644 index 0000000..610df5b --- /dev/null +++ b/src/main/java/com/dvl/adobesign/config/AdobeSignConfig.java @@ -0,0 +1,16 @@ +package com.dvl.adobesign.config; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "bean") +@Getter +@Setter +public class AdobeSignConfig { + + private String message = "Default message from backend is: %s
Services : %s"; + +} diff --git a/src/main/java/com/dvl/adobesign/controller/ContactController.java b/src/main/java/com/dvl/adobesign/controller/ContactController.java index 267e972..594334d 100644 --- a/src/main/java/com/dvl/adobesign/controller/ContactController.java +++ b/src/main/java/com/dvl/adobesign/controller/ContactController.java @@ -1,5 +1,6 @@ package com.dvl.adobesign.controller; +import com.dvl.adobesign.config.AdobeSignConfig; import com.dvl.adobesign.model.Contract; import com.dvl.adobesign.service.ContractService; import org.springframework.core.io.InputStreamResource; @@ -22,13 +23,17 @@ public class ContactController { private final ContractService contractService; - public ContactController(ContractService contractService) { + private final AdobeSignConfig adobeSignConfig; + + public ContactController(ContractService contractService, AdobeSignConfig adobeSignConfig) { this.contractService = contractService; + this.adobeSignConfig = adobeSignConfig; } @GetMapping(value = "/") public String index(Model model) { model.addAttribute("contracts", contractService.getContracts()); + model.addAttribute("message", adobeSignConfig.getMessage()); return "index"; } diff --git a/src/main/resources/templates/index.ftlh b/src/main/resources/templates/index.ftlh index c127ca6..b9fe098 100644 --- a/src/main/resources/templates/index.ftlh +++ b/src/main/resources/templates/index.ftlh @@ -28,5 +28,6 @@ +
Message from the config: ${message}
\ No newline at end of file