How to use env file on Spring Boot - hou27/spring-boot-jwt-example Wiki

Profile

Set application.yml to use .env file

spring:
  config:
    import: optional:file:.env[.properties]

then you can use env file on yml file like this :

jwt:
  token:
    access-token-secret-key: ${ACCESS_TOKEN_SECRET_KEY}
    ...
    refresh-token-secret-key: ${REFRESH_TOKEN_SECRET_KEY}
    ...

env file looks like this

ACCESS_TOKEN_SECRET_KEY=aG91Mjctc2ltcGxlLXNwcmluZy1ib290LWFwaS1qd3QK
REFRESH_TOKEN_SECRET_KEY=cmVmcmVzaHRva2Vuc2VjcmV0a2V5Cg==