0

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;
Sebastian S
  • 4,420
  • 4
  • 34
  • 63

1 Answers1

0

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.

Sebastian S
  • 4,420
  • 4
  • 34
  • 63