If you have access to the JAX-RS API and an implementation in your projects (many do), then you can use JAX-RS’
UriBuilder to conveniently create URIs via builder pattern using resolvable placeholder.
Have a look at the following example:
Depending on whether the system properties are present, the resulting
uri will be
http://localhost:8080/examples/123?sort=name, or any host and port which is overridden.
This is a convenient way to create flexible URIs for tests where the target system may change for different scopes. This API is available in everything that supports JAX-RS, for example Open Liberty, Quarkus, or other Jakarta or MicroProfile implementations.
This post has been reposted from my newsletter issue 040.