I have two spring profile files application-test.yml
and application-prod.yml
, with some properties in each file.
I have set
spring:
profiles:
active: test, prod
in my application.yml
file and added the @Profile(value= ["test", "prod"])
in my configuration file.
Now, my question is how to read the content of the two files and what do I need to pass in @Value?? This is how I implemented it:
@Profile(value= ["test", "prod"])
@Configuration()
class myMessege(
@Value("${"??????"}")
private val newMessege: String) {
@Bean
fun readMessage {
println(newMessege)
}
The application-test.yml
is
spring.profiles: test
key:
- name: tom
roles:
- student
- teacher
- friend
and the application-prod.yml
is
spring.profiles: test
key:
- name:lisa
roles:
- doctor
- nurse
- patient
How to return the key from both files?