This works:
server.port=8080
myapp.server=http://localhost:${server.port}
but this doesn't
#server.port=8080
myapp.server=http://localhost:${server.port}
In tests, it throws
@SpringBootTest
@ActiveProfiles("test")
public class PropertiesTest {
@Value("${myapp.server}")
String server;
@Test
void test() {
System.out.println();
}
}
outside of tests (I use @ConfigurationProperties), it's simply not resolved (in this case, it would stay http://localhost:${server.port})
Please enable referencing implicit properties too
Comment From: wilkinsona
Thanks for the suggestion. Unfortunately, we cannot do this as property placeholder resolution has no knowledge of a property's implicit default value. In some cases, an implicit default can change based on the value of other properties making it impossible to provide an accurate view of all of the possible defaults during property binding.
For cases where you know what the default will be or what you want it to be, you can provide a default in the placeholder:
${server.port:8080}