Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set enviromment variable in Maven

I got an spring boot app with the following application.properties setting.

#...
spring.datasource.url=${JDBC_DATABASE_URL}

When I use an IDE like IntelliJ I can set the environment variable and it woks when I start the app.

But now I want to start my app over the console with maven mvn spring-boot:run . How can I set the environment variable here?

like image 843
Tom Avatar asked Oct 29 '22 21:10

Tom


1 Answers

From spring-boot version 2 argline key run.jvmArguments replaced for spring-boot.run.jvmArguments: https://docs.spring.io/spring-boot/docs/current/maven-plugin/reference/htmlsingle/#run-example-debug . So correct command is:

mvn spring-boot:run -Dspring-boot.run.jvmArguments="-DJDBC_DATABASE_URL=jdbc:..."
like image 76
Alexander Radchenko Avatar answered Nov 09 '22 17:11

Alexander Radchenko