简体   繁体   English

使用属性启动Spring Boot

[英]Spring boot run with properties

I want to pass properties for spring boot project from command line. 我想从命令行传递spring boot项目的属性。 I have following configuration in my yaml config file: 我的yaml配置文件中有以下配置:

server:
    port: ${port}

but when I starts project from command line like: 但是当我从命令行启动项目时,例如:

java -jar myapp.jar -Dport=8085

I get following error: 我收到以下错误:

 Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'port' in value "${port}" 

Did I miss anything in my configuration? 我错过了配置中的任何内容吗?

尝试这个

java -Dserver.port=8085 -jar myapp.jar

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM