'Quarkus profile-aware config isn't used in native compilation
I'm using quarkus profile-aware files to set different property values for different profiles:
- application.properties
quarkus.http.port=9090 # quarkus.http.port is just an example property
- application-staging.properties
quarkus.http.port=9190
This works if I don't enable native-image compilation: if QUARKUS_PROFILE
environment variable is staging
, Quarkus will pick up the correct property value (i.e. 9190
).
However, when I do native compilation (quarkus.package.type=native
) it seems quarkus is using the default value (9090
); the profile-aware file is ignored by the native binary. "Profile in the property name" still works (i.e. %staging.quarkus.http.port=9190
in application.properties).
Is this the expected behavior? Or what am I missing for the native compilation to work with profile-aware files?
Solution 1:[1]
I solved this problem by adding the following line to the application.properties
:
quarkus.native.resources.includes=*.properties
This causes the native compilation process to include all application-*.properties
files from the resources so Quarkus can load the correct one depending on the QUARKUS_PROFILE
environment variable at runtime.
Solution 2:[2]
Using the getting-started quickstart with the addition of application-dummy.properties
quarkus.http.port=9090
when I build the application with mvn package -DskipTests -Dquarkus.profile=dummy -Dnative
then when I run it, it starts on port 9090
as expected
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Zoidberg |
Solution 2 | geoand |