Код: Выделить всё
@PropertySource("classpath:/application.properties")
@Configuration
@ComponentScan("org.example")
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
...
@Value("${app.person.url}")
private String propertyValue;
...
}
Код: Выделить всё
public record Person(String url) {
}
@Bean
public Person getFromProperty() {
return new Person(propertyValue);
}
Код: Выделить всё
@GetMapping("/data")
public Person data() {
return context.getBean(Person.class);
}
Код: Выделить всё
{
"url": null
}
Я пытался добавить статический компонент типа PropertySourcesPlaceholderConfigurer, но это не работает.
Подробнее здесь: https://stackoverflow.com/questions/790 ... s-get-null