I Am trying to add an environmental variable inside my spring-boot application.properties
file. I know how to add it normally on a non spring-boot project, but I cannot find the field for adding environment variables, this is all I see:
This is my application.properties file, this may help.
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/FTHLDB
spring.datasource.username=root
spring.datasource.password=${MYSQL_PASS}
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.format_sql=true
CodePudding user response:
you can write the environment variable name directly with it's value like this
myvariable = its value
inside the application.properties file
and to use it just inject it inside your method or globally inside your class like this public class MyClass{ @Value("${myvariable}"} String myvariable; }
CodePudding user response: