'Multi module spring project not taking application.properties
I'm trying to build a multi module application with one parent POM and different submodules. The main submodule (entrypoint) is a web app with his own application.properties, and it uses other modules as libraries. The structure is like this:
-parent project
|
|- webapp
| |- src/main/java/..
| |- src/main/resources/application.properties
|
|- submodule
|- src/main/java/...
|- src/main/resources/submodule.properties
In the submodule, the configuration class is like this:
package com.project.submodule.conf;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@PropertySource(value = "classpath:submodule.properties" )
public class SubModuleConfig{
}
but it still can't take the correct properties, as i have some ConditionalOnProperty that basically work idependently of the properties that i've set in the submodules. If i set the same property on the webapp project (in application.properties) then, they are correctly taken and ConditionalOnProperty works as expected. How can i do?
--- EDIT ---
It seems that the properties are correclty loaded from submodules AFTER the ConditionalOnProperty is evaluated. So ConditionalOnProperty evaluates basing on the application.properties (which are for some reason loaded first and not togheter with submodule.properties), then submodule.properties load but at this point the conditionalOnProperty was already evaluated not taking into account submodule.properties. Is there a way to specify the correct property loading flow?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
