Failed to run SB using Eclipse IDE run command using environment variables in application properties

Since GitGuardian noticed that I push hardcoded password I decided to create .env files. However the application cannot load these variables values from the shell context and instead it is using placeholders and then fail to load the database and thus the application. What should I do? I have such application properties:
server.port=9400
spring.datasource.url=jdbc:mysql://localhost:3306/......
spring.datasource.username=${DATABASE_USERNAME}
spring.datasource.password=${DATABASE_PASSWORD}

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# Enable Hibernate SQL logging
logging.level.org.hibernate.SQL=DEBUG

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
# Maximum size allowed for file uploads
spring.servlet.multipart.max-file-size=40MB
# Maximum size allowed for multipart/form-data requests
spring.servlet.multipart.max-request-size=40MB
server.port=9400
spring.datasource.url=jdbc:mysql://localhost:3306/......
spring.datasource.username=${DATABASE_USERNAME}
spring.datasource.password=${DATABASE_PASSWORD}

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# Enable Hibernate SQL logging
logging.level.org.hibernate.SQL=DEBUG

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto=update
# Maximum size allowed for file uploads
spring.servlet.multipart.max-file-size=40MB
# Maximum size allowed for multipart/form-data requests
spring.servlet.multipart.max-request-size=40MB
But when I start the application directly from Eclipse IDE by choosing command: Run as.. > Spring Boot App then it starts and encounters errors: What to do?
No description
3 Replies
JavaBot
JavaBot8mo ago
This post has been reserved for your question.
Hey @Tomasm21! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Tomasm21
Tomasm21OP8mo ago
The application successfully launches on bash terminal using command:
./mvnw spring-boot:run -Dspring-boot.run.jvmArguments="-DDATABASE_USERNAME=$DATABASE_USERNAME -DDATABASE_PASSWORD=$DATABASE_PASSWORD"
./mvnw spring-boot:run -Dspring-boot.run.jvmArguments="-DDATABASE_USERNAME=$DATABASE_USERNAME -DDATABASE_PASSWORD=$DATABASE_PASSWORD"
When in terminal I load source for env: $ source .env it is acquired well. I can echo my variables:
$ echo $DATABASE_PASSWORD
pass1234
$ echo $DATABASE_USERNAME
Tomasm21
$ echo $DATABASE_PASSWORD
pass1234
$ echo $DATABASE_USERNAME
Tomasm21
But if I launch my app using ./mvnw spring-boot:run then it finds same Caused by: java.sql.SQLException: Access denied for user '${DATABASE_USERNAME}'@'localhost' (using password: YES) errors. But while developing I used to launch directly on Eclipse by right clicking the main class file and selecting Run as... > Spring Boot App. Why by default my environment variables cannot be read? I'm on Windows 10 OS.
JavaBot
JavaBot8mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
Want results from more Discord servers?
Add your server