如何覆盖 Quarkus 中的属性? [英] How can I override properties in Quarkus?

查看:68
本文介绍了如何覆盖 Quarkus 中的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的 Quarkus 应用程序中覆盖我在配置文件中配置的属性.

I would like to override the properties I have configured in my configuration file in my Quarkus application.

我怎样才能做到这一点?

How can I accomplish that?

推荐答案

Quarkus 中的属性一般在 src/main/resources/application.properties 中配置.

Properties in Quarkus are generally configured in src/main/resources/application.properties.

这对于配置 Quarkus 行为的属性(例如它侦听的 http 端口或要连接的数据库 URL)和特定于您的应用程序的属性(例如 greeting.xml )都是正确的.message 属性).

This is true both for properties that configure the behavior of Quarkus (like the http port it listens to or the database URL to connect to for example) and properties that are specific to your application (for example a greeting.message property).

前者的可覆盖性取决于相关配置.例如,http 属性(如 quarkus.http.port)是可覆盖的.

The overridability of the former depends on the configuration in question. For example, the http properties (like quarkus.http.port) are overridable.

后者在运行时总是可覆盖的.

The later are always overridable at runtime.

例如,在 JVM 模式下运行 Quarkus 应用程序时,您可以执行以下操作:

When running a Quarkus application in JVM mode you can, for example, do:

java -Dgreeting.message=hi -jar example-runner.java

同样,当运行使用 GraalVM(特别是SubstrateVM 系统),你可以这样做:

Similarly, when running a Quarkus application that has been converted to a native binary using the GraalVM (specifically the SubstrateVM system), you could do:

./example-runner -Dgreeting.message=hi

可以在Quarkus - 配置您的应用程序上找到更多信息"官方指南

More information can be found on the "Quarkus - Configuring Your Application" official guide

这篇关于如何覆盖 Quarkus 中的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆