我在 build.gradle 中有以下片段。
buildscript {
ext {
springBootVersion = '1.5.12.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
..
bootRun {
systemProperties = System.properties
}
..
我使用以下命令运行应用程序。
./gradlew bootRun -PjvmArgs=-Dserver.port=8090
但是它不起作用。我应该更改什么才能使用指定端口运行应用程序,就像我在 application.properties 中所做的那样。
server.port=8090
最佳答案
根据您的配置,这应该可以工作:
./gradlew bootRun -Dserver.port=8090
使用这段代码:
bootRun {
systemProperties = System.properties
}
您将System
属性传递给将运行的应用程序。 -P
用于项目属性。
关于java - 使用参数通过 bootRun 使用 gradle 运行 spring boot 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49958043/