Hi Team
I am getting error for , this example is from the Spring boot docs. any help appreciated
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'local.server.port' in value "${local.server.port}"
at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders(PropertyPlaceholderHelper.java:124) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders(AbstractPropertyResolver.java:236) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.core.env.AbstractPropertyResolver.resolveRequiredPlaceholders(AbstractPropertyResolver.java:210) ~[spring-core-5.2.3.RELEASE.jar:5.2.3.RELEASE]
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.lambda$processProperties$0(PropertySourcesPlaceholderConfigurer.java:175) ~[spring-context-5.2.3.RELEASE.jar:5.2.3.RELEASE]"
Test
@SpringBootTest(classes = { TestApplication.class}, webEnvironment = RANDOM_PORT)
public class ELFSpringWebAutoConfigurationTest {
@LocalServerPort
int port;
@Autowired
TestRestTemplate restTemplate;
@Test
void testRestCall() {
assertThat(this.restTemplate.getForObject("http://localhost:" + port + "/",
String.class)).contains("Hello, World");
}
}
@Value(value="${local.server.port}")
int port;
webEnvironment = RANDOM_PORT
. disregard my comment