Java Spring Boot-application.properties中的程序参数

Java Spring Boot-application.properties中的程序参数,java,spring-boot,properties,Java,Spring Boot,Properties,如何在应用程序.properties中包含程序参数 例如:javadspring boot.run.arguments=--redis.host=localhost-jarbuild/libs/app.jar application.properties: spring.redis.url=redis://${redis.host}:6379 是否可以用来自程序参数的值替换${redis.host}?(示例中的localhost)您只需传递属性,如-Dredis.host=localhost

如何在
应用程序.properties
中包含程序参数

例如:
javadspring boot.run.arguments=--redis.host=localhost-jarbuild/libs/app.jar

application.properties:

spring.redis.url=redis://${redis.host}:6379

是否可以用来自程序参数的值替换${redis.host}?(示例中的localhost)

您只需传递属性,如
-Dredis.host=localhost

java -Dredis.host=localhost -jar <your jar>
java-Dredis.host=localhost-jar

您只需传递属性,如
-Dredis.host=localhost

java -Dredis.host=localhost -jar <your jar>
java-Dredis.host=localhost-jar

您可能需要使用
属性SourcePlaceHolderConfiguration
。您需要使用SpringBoot传递属性,如
-Dredis.host=localhost
@Ivan,将属性作为-Dredis.host=localhost单独传递可以解决问题。如果您将此信息作为答案填写,我将接受此信息作为正确答案。您可能需要使用
propertysourceplaceholderconfigure
。您需要使用SpringBoot传递属性,如
-Dredis.host=localhost
@Ivan,将属性作为-Dredis.host=localhost单独传递可以解决问题。我会接受这个信息作为正确的答案,如果你写它作为一个答案。