'spring boot: how to verify env variables?

Is it possible to check env vars on startup in Spring Boot? For example config looks like this:

spring:
  data:
    mongodb:
      uri: ${MONGODB_URI}
  rabbitmq:
    addresses: ${RMQ_CLUSTER_ADDRESSES}

I want the app to not start if one of var is not exists.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source