spring profiles in .yaml. How do you set up configuration properties?

Viewed 3293

I am a spring newbie and a .yaml newbie as well and I´m starting to get cross eyed googling answers(a lot of them are very outdated or just confusing).

Currently I have a application.yaml that looks like this

spring:
  profiles.active: TEST
---
spring:
  profiles: DEV
logging:
  level:
    org.springframework.web: INFO
    se.some.url: DEBUG
api:
  url:
     one: test.url
    two : test.url
certification:
  policies:
      one : 0.0.0.0.0
      two : 0.0.30.0

---
spring:
  profiles: TEST
logging:
  level:
    org.springframework.web: INFO
    se.some.url: DEBUG
api:
  url:
     one: test.url
    two : test.url
certification:
  policies:
      one : 0.0.0.0.0
      two : 0.0.30.0

I need to be able to use the values of the certification.policies and api.url in my code and make sure everything loads depending on with profile is active.

I do get that a config class needs to be created.

But what annotation should be used? How do I set the profile? How do I get the value?

Grateful for any help!

1 Answers
Related