1

Suppose I have 2 SpringBoot projects. Both of them have their own profile properties like (application.properties, application-dev.properties and so on). Now I import one project into another.

Now because of this, there are two sets of properties for each profile(parent and child project). How do I know which property file gets picked up. Is it from parent project or child project? Or it simply overrides the properties from child project for the common properties keys?

What is the best way to handle such scenarios?

The usecase is: I have 3-4 projects working on same database. So I created a common SpringBoot project in which i have mentioned SpringBoot JPA properties which creates the EntityManager and other datasources.

application.properties(Parent project)

spring.jpa.*= some values 

The above common project I am using as a dependency in the other SpringBoot project.

application.properties(Child project)

spring.kafka.* = some values

Now I want both the properties to be read if we deploy the child project, so that JPA as well as Kafka configuration works.

If you try with renaming the property file in parent project. Problem with that solution is when u add application-shared*.properties in parent project. Whenever u add new profile like dev, dev-blue,dev-green in your child project, it looks for application-shared-dev-blue, application-shared-dev-green and so on in the parent project and gives file not found exception. So that solution clearly not helping.

Any ideas on this

  • Hi, Look into this: https://stackoverflow.com/questions/44718763/how-to-inherit-application-properties-in-spring –  Apr 15 '19 at 06:38
  • Possible duplicate of [How to inherit application.properties in Spring?](https://stackoverflow.com/questions/44718763/how-to-inherit-application-properties-in-spring) –  Apr 15 '19 at 06:38
  • No I have already tried that solution and then posted here. Problem with that solution is when u add application-shared*.properties in parent project. Whenever u add new profile like dev, dev-blue,dev-green in your child project, it looks for application-shared-dev-blue, application-shared-dev-green and so on in the parent project and gives file not found exception. So that solution clearly not helping. – stephen fernandes Apr 15 '19 at 16:26

0 Answers0