CodexBloom - Programming Q&A Platform

Java 17 - Difficulty with Spring Boot Application scenarios to Load Custom Configuration Properties

👀 Views: 1 đŸ’Ŧ Answers: 1 📅 Created: 2025-06-06
spring-boot configuration yaml Java

I tried several approaches but none seem to work. I'm updating my dependencies and I'm having trouble with I'm working on a project and hit a roadblock... This might be a silly question, but I'm experiencing an scenario with my Spring Boot application where it fails to load custom configuration properties from an external YAML file. Despite having the properties file correctly placed in the `src/main/resources` directory, I'm getting the following behavior on startup: ``` Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat ``` I have a `@ConfigurationProperties` class set up like this: ```java @ConfigurationProperties(prefix = "app.config") public class AppConfig { private String setting1; private int setting2; // Getters and Setters } ``` In my `application.yml`, I have: ```yaml app: config: setting1: "value1" setting2: 10 ``` I also added the `@EnableConfigurationProperties(AppConfig.class)` annotation in my main application class, but I'm still working with issues. I've tried running the application with `--spring.config.location=classpath:/application.yml`, but it doesn't seem to have any effect. I also verified that the YAML file has the correct format and is undamaged. The scenario continues even after cleaning and rebuilding the project. Is there anything I might be overlooking in terms of Spring Boot's configuration property binding? Any help would be greatly appreciated. Any ideas what could be causing this? I'm working with Java in a Docker container on Linux. This is part of a larger service I'm building. How would you solve this? I'm developing on Windows 11 with Java. Could someone point me to the right documentation?