如何覆盖 spring 引导属性?

How to override spring boot properties?

如何在运行时覆盖 spring 启动属性?

以下命令在终端中运行正常

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

但它在 Eclipse 中不起作用

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

你有两个选择。

  1. 您可以在 spring 引导应用程序的 application.properties 文件中配置 server.port=8081
  2. 如图所示,在 eclipse 的 VM 参数中仅配置 -Dserver.port=8081

使用 -Dserver.port=8081 作为 eclipse 运行 配置中的 vm 参数。它会起作用