I am having trouble to use external configuration properties for my Quarkus application.
I want to override the database properties. The application.properties inside the project has properties for dev and test, not for prod. The values for prod are inside the external application.properties.
I read the official guide (https://quarkus.io/guides/config#overriding-properties-at-runtime) and tried to place an application.properties file in a folder next to the runner-jar called config. That didn't work. But just passing the properties on the command line didn't work either.
C:.
│ 0.1.0-SNAPSHOT-runner.jar
│ 0.1.0-SNAPSHOT.jar.original
│
├───config
│ application.properties
Internal:
%dev.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/postgres
%dev.quarkus.datasource.username=postgres
%dev.quarkus.datasource.password=postgres
%dev.quarkus.datasource.db-kind=postgresql
%dev.quarkus.hibernate-orm.database.generation=none
%test.quarkus.datasource.jdbc.url=jdbc:h2:mem:test
%test.quarkus.datasource.username=sa
%test.quarkus.datasource.password=
%test.quarkus.datasource.db-kind=h2
%test.quarkus.hibernate-orm.database.generation=none
External:
quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/postgres
quarkus.datasource.username=postgres
quarkus.datasource.password=postgres
quarkus.datasource.db-kind=postgresql
quarkus.hibernate-orm.database.generation=none
With java -jar .\0.1.0-SNAPSHOT-runner.jar
I get the following error:
2020-07-24 16:58:16,666 ERROR [io.qua.application] (main) Failed to start application: java.lang.IllegalArgumentException: Parameter 'dataSource' may not be null
at org.wildfly.common.Assert.checkNotNullParamChecked(Assert.java:71)
at org.wildfly.common.Assert.checkNotNullParam(Assert.java:49)
at org.wildfly.security.auth.realm.jdbc.QueryConfiguration.<init>(QueryConfiguration.java:40)
at org.wildfly.security.auth.realm.jdbc.QueryBuilder.buildQuery(QueryBuilder.java:76)
at org.wildfly.security.auth.realm.jdbc.JdbcSecurityRealmBuilder.build(JdbcSecurityRealmBuilder.java:51)
at io.quarkus.elytron.security.jdbc.JdbcRecorder.createRealm(JdbcRecorder.java:42)
at io.quarkus.deployment.steps.ElytronSecurityJdbcProcessor$configureJdbcRealmAuthConfig-173765586.deploy_0(ElytronSecurityJdbcProcessor$configureJdbcRealmAuthConfig-173765586.zig:76)
at io.quarkus.deployment.steps.ElytronSecurityJdbcProcessor$configureJdbcRealmAuthConfig-173765586.deploy(ElytronSecurityJdbcProcessor$configureJdbcRealmAuthConfig-173765586.zig:36)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:524)
at io.quarkus.runtime.Application.start(Application.java:90)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:91)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
2020-07-24 16:58:16,730 ERROR [io.qua.run.Application] (main) Error running Quarkus application: java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:649)
at io.quarkus.runtime.Application.start(Application.java:90)
at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:91)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
Caused by: java.lang.IllegalArgumentException: Parameter 'dataSource' may not be null
at org.wildfly.common.Assert.checkNotNullParamChecked(Assert.java:71)
at org.wildfly.common.Assert.checkNotNullParam(Assert.java:49)
at org.wildfly.security.auth.realm.jdbc.QueryConfiguration.<init>(QueryConfiguration.java:40)
at org.wildfly.security.auth.realm.jdbc.QueryBuilder.buildQuery(QueryBuilder.java:76)
at org.wildfly.security.auth.realm.jdbc.JdbcSecurityRealmBuilder.build(JdbcSecurityRealmBuilder.java:51)
at io.quarkus.elytron.security.jdbc.JdbcRecorder.createRealm(JdbcRecorder.java:42)
at io.quarkus.deployment.steps.ElytronSecurityJdbcProcessor$configureJdbcRealmAuthConfig-173765586.deploy_0(ElytronSecurityJdbcProcessor$configureJdbcRealmAuthConfig-173765586.zig:76)
at io.quarkus.deployment.steps.ElytronSecurityJdbcProcessor$configureJdbcRealmAuthConfig-173765586.deploy(ElytronSecurityJdbcProcessor$configureJdbcRealmAuthConfig-173765586.zig:36)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:524)
... 6 more
With java -Dquarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/postgres -Dquarkus.datasource.username=postgres -Dquarkus.datasource.password=postgres -Dquarkus.datasource.db-kind=postgresql -jar .\0.1.0-SNAPSHOT-runner.jar
I get this:
Error: Could not find or load main class .datasource.jdbc.url=jdbc:postgresql:..localhost:5432.postgres
Caused by: java.lang.ClassNotFoundException: /datasource/jdbc/url=jdbc:postgresql://localhost:5432/postgres
I could only find two similar threads (How can I override properties in Quarkus? and https://github.com/quarkusio/quarkus/issues/1218). Both mention the method with the application.properties in the config folder. Since this does not work for me and I cannot find any new information, I am somewhat lost ...
I would be grateful for any help!