I have an OpenFeign client set up like this:
@FeignClient(name = "myService", qualifier = "myServiceClient", url = "${myservice.url}")
public interface MyServiceClient {
...
}
and a Spring Boot test set up like this:
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = MyApplication.class)
@RunWith(SpringRunner.class)
@EnableFeignClients(clients = MyServiceClient .class)
public class ReservationSteps {
...
}
The test is supposed to spin up the application and send a request to it using the Feign client.
The problem is the RANDOM_PORT value.
How do I declare the "myservice.url" property in the properties file so it includes the correct port?
I have tried this:
myservice.url=localhost:${local.server.port}
but it results in "localhost:0".
I don't want to use a constant value for the port.
Please help. Thanks!