如何在Spring注释

时间:2017-10-27 19:21:22

标签: java spring spring-boot

我正在使用Spring-Dalston发布的Wiremock for Integration测试。 我想启动一个WireMock服务器以替换云配置配置。因此,我这样做:

@RunWith(SpringRunner.class)
@SpringBootTest(properties = { "spring.cloud.config.uri=http://localhost:12345", "eureka.client.enabled=false",
        "spring.datasource.url=jdbc:h2:mem:ingest;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" }, webEnvironment = WebEnvironment.RANDOM_PORT, classes = Application.class)
public class RssApplicationTests {

    @ClassRule
    public static WireMockClassRule wiremock = new WireMockClassRule(WireMockSpring.options().port(12345));

但属性spring.cloud.config.uri中的端口是硬编码的,我无法告诉Spring为spring.cloud.config.uri

添加特定的(随机端口)

我正在搜索类似

的内容
@RunWith(SpringRunner.class)
@SpringBootTest(properties = { "spring.cloud.config.uri=http://localhost:{$local.server.port}",

有可能吗?

0 个答案:

没有答案