我收到了一個彈出式啓動應用程序,其中包含以下application.properties
設置。在Maven中設置環境變量
#...
spring.datasource.url=${JDBC_DATABASE_URL}
當我使用IDE的IntelliJ一樣,我可以設置環境變量,當我啓動應用程序它炒菜。
但現在我想通過控制檯與maven mvn spring-boot:run
啓動我的應用程序。我怎樣才能在這裏設置環境變量?
我收到了一個彈出式啓動應用程序,其中包含以下application.properties
設置。在Maven中設置環境變量
#...
spring.datasource.url=${JDBC_DATABASE_URL}
當我使用IDE的IntelliJ一樣,我可以設置環境變量,當我啓動應用程序它炒菜。
但現在我想通過控制檯與maven mvn spring-boot:run
啓動我的應用程序。我怎樣才能在這裏設置環境變量?
嘗試此
mvn spring-boot:run -DvariableName=variableValue
經由控制檯變量傳遞到該應用
要通過JVM參數到彈簧的應用中使用:
mvn spring-boot:run -Drun.jvmArguments="-Dspring.datasource.url=jdbc:postgresql://localhost/mydb?user=postgres&password=postgres"
或
mvn spring-boot:run -Drun.jvmArguments="-DJDBC_DATABASE_URL=jdbc:postgresql://localhost/mydb?user=postgres&password=postgres"
見http://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-debug.html
這樣? '''mvn spring-boot:run -DvariableName = JDBC_DATABASE_URL = jdbc:postgresql:// localhost/mydb?user = postgres&password = postgres'''它不工作... – Tom