From 40727e08c4636a9648414a446b33fc8b9d00d0e6 Mon Sep 17 00:00:00 2001 From: "Gumparthy Pavan Kumar[pk]" Date: Tue, 19 Nov 2024 22:01:29 +0530 Subject: [PATCH] fix: Update @Value annotations and properties-maven-plugin configuration to enable proper property loading in fat JAR 1. What Changed? * Updated the @Value annotations in controller to correctly reference properties, now using {} i.e @Value("${property.key}") * Updated the properties-maven-plugin execution phase from package -> initialize to ensure property files are included into the final JAR 2. What is the reason for change? * The original code had @Value annotations without curly brackets as a result spring does not resolve properties, and application did not throw errors even though properties were not being loaded * The previous configuration of properties-maven-plugin did not copy property files in generated JAR 3. Is there anything to watch out for anything particularly remarkable? * This fix addresses the issue of missing properties and inconsistent property resolution. There is nothing remarkable to note beyond standard fixes --- pom.xml | 2 +- .../java/tutorial/buildon/aws/o11y/HelloAppController.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index f5be7ab..a40fd3c 100644 --- a/pom.xml +++ b/pom.xml @@ -91,7 +91,7 @@ 1.2.0 - package + initialize write-project-properties diff --git a/src/main/java/tutorial/buildon/aws/o11y/HelloAppController.java b/src/main/java/tutorial/buildon/aws/o11y/HelloAppController.java index 3f931e4..5db9db5 100644 --- a/src/main/java/tutorial/buildon/aws/o11y/HelloAppController.java +++ b/src/main/java/tutorial/buildon/aws/o11y/HelloAppController.java @@ -26,10 +26,10 @@ public class HelloAppController { private static final Logger log = LoggerFactory.getLogger(HelloAppController.class); - @Value("otel.traces.api.version") + @Value("${otel.traces.api.version}") private String tracesApiVersion; - @Value("otel.metrics.api.version") + @Value("${otel.metrics.api.version}") private String metricsApiVersion; private final Tracer tracer =