Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profile Inheritage In spring boot

Is it possible to have a profile in spring boot and also another profile that inherits most of the parent values and beans?

For example I have two profiles staging and staging-task. I want staging-task to inherit the database configuration of the staging profile however I want it to override the jpa configuration.

Is profile inheritance available to @Configuration beans.

like image 956
gkatzioura Avatar asked Mar 09 '23 10:03

gkatzioura


1 Answers

Yes. Its possible to have spring profiles in spring boot. For your problem, put your common database configuration in application.yml(default profile).

And you can override the other properties in application-stage.yml.

Spring will read the properties from application.yml and override from application-stage.yml when active profile is stage.

like image 114
Jaydeep Rajput Avatar answered Mar 19 '23 17:03

Jaydeep Rajput