Sebastian S
Sebastian S

Reputation: 4712

Quarkus Dev Services: What port do they run on?

I'm running keycloak as a dev service and I'm aware that I could configure a fixed port using quarkus.keycloak.devservices.port. However for this question, let's assume I use a system-assigned port.

Question: Now how do I (programmatically, with the means of Quarkus) find out, what port the dev service is running on?

I tried injecting this config value, however this results in an error when I don't specify it myself:

@ConfigProperty(name = "quarkus.keycloak.devservices.port")
String devServicePort;

Upvotes: 0

Views: 840

Answers (1)

Sebastian S
Sebastian S

Reputation: 4712

The problem seems to be that quarkus.keycloak.devservices.port is "fixed at build time". However injecting the following property works:

@ConfigProperty(name = "quarkus.oidc.auth-server-url")
String oidcUrl;

This gives me http://localhost:52333/auth/realms/quarkus, so I can then extract the port from it.

This answer is specific to keycloak - but other dev services have similar properties.

Upvotes: 0

Related Questions