春天的云传递参数

问题描述 投票:0回答:1

我已经用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/
java spring-boot gradle spring-cloud-config
1个回答
0
投票

试着在build.gradle文件中配置bootrun任务,如下图所示。

bootRun {
    systemProperties System.properties
}

0
投票

我在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/
© www.soinside.com 2019 - 2024. All rights reserved.