我已经用spring cloud config配置了应用程序,我想通过jvm agrument来运行这个应用程序。
Bootrap.yml 配置
spring.application.name: app
spring.cloud.config:
enabled: ${SPRING_CONFIG_ENABLED:false}
uri: ${SPRING_CONFIG_URI:http://ip:9097/}
我想传递这样的参数,但不能工作。
gradle bootRunLocal -DSPRING_CONFIG_ENABLED=true -DSPRING_CONFIG_URI=http://localhost:9097/
试着在build.gradle文件中配置bootrun任务,如下图所示。
bootRun {
systemProperties System.properties
}
我在bootRun中添加了以下代码来解决这个问题。
bootRun {
if (project.hasProperty('args')) {
args project.args.split(',')
}
}
来运行任务。
gradle bootRun -Pargs=--spring.profiles.active=local,--SPRING_CONFIG_ENABLED=true,--SPRING_CONFIG_URI=http://localhost:9097/