Unable to Configure Spring Boot Application Properties to Support Multiple Profiles in Java 17
I need some guidance on I'm experimenting with I'm experimenting with I tried several approaches but none seem to work. I'm currently working on a Spring Boot application and I'm having trouble setting up multiple profiles correctly. I want to load different application properties based on the active profile, but it seems that my application is always defaulting to the 'application.properties' file, regardless of which profile I activate. I've defined the following profiles in my `application.yaml`: ```yaml spring: profiles: active: dev --- spring: profiles: dev datasource: url: jdbc:h2:mem:devdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE username: sa password: --- spring: profiles: prod datasource: url: jdbc:mysql://localhost:3306/proddb username: produser password: prodpass ``` When I run the application with `-Dspring.profiles.active=prod`, I expect it to use the configuration settings defined under the `prod` profile. However, it seems to still be using the default `dev` settings from `application.properties`. I've tried multiple approaches: - I confirmed that I'm passing the profile correctly when starting the application. - I checked the environment variable settings, and they seem correct. - I even attempted to rename `application.yaml` to `application-prod.yaml`, but that didn't change anything. The output still indicates it's using the `dev` datasource settings: ``` 2023-10-05 10:00:00.000 INFO 12345 --- [ main] com.example.demo.DemoApplication : Starting DemoApplication on my-computer with PID 12345... 2023-10-05 10:00:00.001 INFO 12345 --- [ main] o.s.b.d.a.DataSourceAutoConfiguration : Using data source: jdbc:h2:mem:devdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE ``` Could anyone advise on what I might be missing here? Is there an additional configuration I need to consider for profile management in Spring Boot 2.7 with Java 17? Am I missing something obvious? I appreciate any insights! The project is a desktop app built with Java. Any suggestions would be helpful. For context: I'm using Java on macOS. I'd really appreciate any guidance on this.