My maven project has three modules:
Dummy-project
- Module A
- Module A1
- Module A2
- src/main
- java
- HttpMetaDataUtil.java
- resources
- config/beta
- application.properties
- Module B
- src/main
- resources
- config/beta
- application.properties
- Module C
In module A2, using file HttpMetaDataUtil.java, I want to read contents from properties file (residing inside module A2 only).
HttpMetaDataUtil.java
@Getter
@Setter
@Component
@PropertySource("classpath:config/beta/application.properties")
@ConfigurationProperties(prefix = "api.verification")
public class HttpMetaDataUtil {
private Map<String, String> smartCard;
}
Module A2/src/main/resources/config/beta/application.properties
# SmartCard related properties
api.verification.smartCard.path=https:dummy_data
api.verification.smartCard.retryDelay=1000
api.verification.smartCard.serviceTimeout=30000
But smartCard map is getting set as null.
When I put the above properties config in Module B/src/main/resources/config/common/application.properties, it is taking the properties from this file.
Module B/src/main/resources/config/beta/application.properties
# SmartCard related properties
api.verification.smartCard.path=https:dummy_data
api.verification.smartCard.retryDelay=1000
api.verification.smartCard.serviceTimeout=30000
This means that HttpMetaDataUtil.java (residing under module A2) has classpath set for Module B.
I verified it by changing the @PropertySource line in HttpMetaDataUtil.java to @PropertySource("classpath:config/beta/application_new.properties")
and creating application_new.properties file only in module A2, and it is throwing fileNotFound exception.
java.io.FileNotFoundException: class path resource [config/beta/application_new.properties] cannot be opened because it does not exist
When I created application_new.properties file also in module B, it is picking properties from this file.
Can anyone please tell why Module A2 class is picking properties from Module B? Is something I am missing related to classpath?