I have a project, let's call it BaseProject
, which contains a properties file defining different configurations. One of those properties could be security.password.minlength=4
.
Now I have a ProjectA
which builds up on BaseProject
and there for depends on it.
ProjectA
|
|--BaseProject
Now in ProjectA
I would like to have a default security.password.minlength
of 8.
If I simply add a application.properties
file to my ProjectA
, containing security.password.minlength=8
and the specific property is set to 8. Al tough all the other properties form my BaseProject
are ignored now, giving me the exception: java.lang.IllegalArgumentException: Could not resolve placeholder
I still would like to use all properties defined in BaseProject
but solely set the security.password.minlength
to a different value. How can I achieve this?
Update
Currently I let Spring do the handling of the application.properties file. Inside my application, I simply get the values from the Spring environment.
I found the following solution for me:
BaseProject
has a application.properties
which contains all the default values.
ProjectA
has a projectA.properties
which is I integrate with
@PropertySource("projectA.properties")
public class ProjectA {
public static void main(String[] args) {
SpringApplication.run(ProjectA .class, args);
}
}
This allows me to override any property from the BaseProject
project in the projectA.properties
file. The properties which I don't define in projectA.properties
are still taken from the application.properties
of the BaseProject`.