I have a spring boot project in which there are multiple modules, I want to have each module separate application properties file, but when I added properties file in all modules, it's still picking properties from main application properties file.
Project Structure:
|-- Dockerfile
|-- build.gradle
|-- modules
| |-- application
| | |-- build.gradle
| | `-- src
| | `-- main
| | |-- java
| | | `-- org
| | | `-- example
| | | |-- CoreApplication.java
| | `-- resources
| | |-- application-beta.properties
| | |-- application-dev.properties
| | |-- application-local.properties
| | |-- application-prod.properties
| | |-- application-test.properties
| | `-- application.properties
| |-- config-management
| | |-- build.gradle
| | `-- src
| | `-- main
| | |-- java
| | | `-- org
| | | `-- example
| | | `-- controller
| | | `-- TestController.java
| | `-- resources
| | |-- application-beta.properties
| | |-- application-dev.properties
| | |-- application-local.properties
| | |-- application-prod.properties
| | |-- application-test.properties
| | `-- application.properties
`-- settings.gradle
application.properties
in config module
config.hello=hello-from-config
application.properties
in application module
config.hello=hello-from-application
TestController.java
in config module
@RestController
public class TestController {
@Value("${config.hello}")
private String hello;
@GetMapping("hello")
public String get() {
return hello;
}
}
After calling /hello
api, response: hello-from-application