简体   繁体   English

如何覆盖Spring Boot属性?

[英]How to override spring boot properties?

How to override spring boot properties at runtime? 如何在运行时覆盖Spring Boot属性?

Below command works fine in terminal 下面的命令在终端工作正常

    mvn spring-boot:run -Dspring-boot.run.arguments=--server.port=8081

but it's not working in Eclipse 但它在Eclipse中不起作用

    -Dspring-boot.run.arguments=--server.port=8081

运行时参数

You have two options. 您有两个选择。

  1. You can configure server.port=8081 in application.properties file in spring boot application. 您可以在spring boot应用程序的application.properties文件中配置server.port=8081
  2. Configure only -Dserver.port=8081 in VM arguments in eclipse as displayed in the image. -Dserver.port=8081 ,在Eclipse的VM参数中仅配置-Dserver.port=8081

Use -Dserver.port=8081 as vm argument from run configuration of eclipse. 使用-Dserver.port=8081作为Eclipse运行配置中的vm参数。 It will work 会工作的

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

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