Java Spring Boot RandomValuePropertySource嵌套属性

Java Spring Boot RandomValuePropertySource嵌套属性,java,spring,spring-boot,Java,Spring,Spring Boot,是否可以以某种方式“存储”由${random.value}生成的随机值,并在其他属性中将其作为嵌套值引用?我似乎不知道该怎么做 下面是一个场景示例。我希望下面的测试能够通过,但是,foo和bar总是被解析为不同的随机值 import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertThat; import org.junit.Test; import org.junit.runner.RunWi

是否可以以某种方式“存储”由
${random.value}
生成的随机值,并在其他属性中将其作为嵌套值引用?我似乎不知道该怎么做

下面是一个场景示例。我希望下面的测试能够通过,但是,
foo
bar
总是被解析为不同的随机值

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * Created by dustin.schultz on 12/14/15.
 */

@SpringApplicationConfiguration(classes = FooBar.TestApplication.class)
@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource(properties = { "foo=${random.value}", "bar=${foo}" })
public class FooBar
{
    @Value("${foo}")
    private String foo;

    @Value("${bar}")
    private String bar;

    @Test
    public void foo()
    {
        assertThat(foo, is(bar));
    }

    @Configuration
    @EnableAutoConfiguration
    public static class TestApplication
    {

    }
}