From faecaf1ee4d4649cc79d59cb9fd4583bc7a238f2 Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com.> Date: Sat, 4 Jan 2025 12:30:58 +0000 Subject: [PATCH] debugs --- .../software/SPDF/SPdfApplication.java | 1 + .../config/YamlPropertySourceFactory.java | 32 ++++++++++++------- .../SPDF/model/ApplicationProperties.java | 5 +++ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/SPdfApplication.java b/src/main/java/stirling/software/SPDF/SPdfApplication.java index 05cb3229b..c6e69ad11 100644 --- a/src/main/java/stirling/software/SPDF/SPdfApplication.java +++ b/src/main/java/stirling/software/SPDF/SPdfApplication.java @@ -80,6 +80,7 @@ public class SPdfApplication { app.addInitializers(new ConfigInitializer()); Map propertyFiles = new HashMap<>(); // External config files + log.info("Settings file: {}", InstallationPathConfig.getSettingsPath()); if (Files.exists(Paths.get(InstallationPathConfig.getSettingsPath()))) { propertyFiles.put( "spring.config.additional-location", diff --git a/src/main/java/stirling/software/SPDF/config/YamlPropertySourceFactory.java b/src/main/java/stirling/software/SPDF/config/YamlPropertySourceFactory.java index 50bc77f87..459fcc215 100644 --- a/src/main/java/stirling/software/SPDF/config/YamlPropertySourceFactory.java +++ b/src/main/java/stirling/software/SPDF/config/YamlPropertySourceFactory.java @@ -9,17 +9,27 @@ import org.springframework.core.env.PropertySource; import org.springframework.core.io.support.EncodedResource; import org.springframework.core.io.support.PropertySourceFactory; +import lombok.extern.slf4j.Slf4j; +@Slf4j public class YamlPropertySourceFactory implements PropertySourceFactory { - @Override - public PropertySource createPropertySource(String name, EncodedResource encodedResource) - throws IOException { - YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); - factory.setResources(encodedResource.getResource()); - - Properties properties = factory.getObject(); - - return new PropertiesPropertySource( - encodedResource.getResource().getFilename(), properties); - } + @Override + public PropertySource createPropertySource(String name, EncodedResource encodedResource) + throws IOException { + YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); + factory.setResources(encodedResource.getResource()); + Properties properties = factory.getObject(); + + // Add debug logging + if (properties != null) { + log.info("Loaded properties count: {}", properties.size()); + properties.forEach((key, value) -> + log.info("Property loaded - Key: {}, Value: {}", key, value)); + } else { + log.warn("No properties loaded from resource"); + } + + return new PropertiesPropertySource( + encodedResource.getResource().getFilename(), properties); + } } diff --git a/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java b/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java index d683d0026..5560954fa 100644 --- a/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java +++ b/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java @@ -15,6 +15,7 @@ import java.util.List; import java.util.stream.Collectors; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.core.Ordered; @@ -40,6 +41,7 @@ import stirling.software.SPDF.model.provider.UnsupportedProviderException; @Configuration @ConfigurationProperties(prefix = "") +@EnableConfigurationProperties(ApplicationProperties.class) @Data @Order(Ordered.HIGHEST_PRECEDENCE) @Slf4j @@ -65,6 +67,9 @@ public class ApplicationProperties { PropertySource propertySource = new YamlPropertySourceFactory().createPropertySource(null, encodedResource); environment.getPropertySources().addFirst(propertySource); + + log.info("Loaded properties: " + propertySource.getSource()); + return propertySource; }