Mushariar
Mushariar

Reputation: 132

Environment variable in spring boot application.yml

I am new in Spring Boot. Trying a set my database credentials in environment variable using

export SPRING_DATASOURCE_USERNAME=scott

export SPRING_DATASOURCE_PASSWORD=tiger
spring:
  datasource:
    type: org.apache.tomcat.jdbc.pool.DataSource
    url: jdbc:oracle:thin:@ip:port/SID
    username: ${SPRING_DATASOURCE_USERNAME}
    password: ${SPRING_DATASOURCE_PASSWORD}

getting invalid username/password error.

Upvotes: 0

Views: 5109

Answers (1)

Karol Dowbecki
Karol Dowbecki

Reputation: 44980

You are setting the environment variables in the shell using export directive however you are running the application from within IntelliJ IDEA.

If you use IntelliJ to start the application you should set the environment variable directly in the IntelliJ runtime configuration, as shown on picture below:

enter image description here

You could add your exports to .profile (or .bashrc) file but this would force you to restart IntelliJ each time this file is modified.

Upvotes: 3

Related Questions