Profile specific application-{profile}.yaml file is not loading in spring boot 2.4.1

36 Views Asked by At

In my project their is a bootstrap.yml file in which they set the spring.profiles.active as 'dev' and i have application-dev.yaml file in the resource folder. when I run the application the bootstrap.yaml file is loaded and set the profile as 'dev'. I am able to see that in the log as The following profiles are active: dev but the application-dev.yaml is not loaded. I am using spring boot 2.4.1.release.

Please see the code below:

bootstrap.yml:

spring: application: name: eureka-server profiles: active: dev cloud: config: uri: http://localhost:8080/ enabled: TRUE name: eureka-server

application-dev.yaml:

server: port: 8081

spring: application: name: eureka-service

if the application load application-dev.yaml then tomcat should use the port as 8081 but tomcat use the default port as 8080. please see the log below.

log image

Please let me know why the application-dev.yaml file is not loaded even if the active profile is set as 'dev'.

When I rename the application-dev.yaml as application.yaml and then removed the active.profile:dev from bootstrap.yaml file then the application load the config and tomcat use the port as 8081.

0

There are 0 best solutions below