I want to configure in my @Configuration
class bean which is already created by other library's autoconfiguration. I just need to change some fields in that class after it's being initialized.
But I can't find a proper way how to provide code block in @Configuration
class and not using @Bean
annotation. Is there an ideomatic way to do so in spring?
One way to do this:
@Configuration
class TestConfig {
@Autowired
private SomeBean someBean;
@PostConstruct
private void initSomeBean() {
// someBean.setProperty("qwe");
}
}
@PostConstruct
annotation defines init-method, which is getting called after SomeBean
is autowired. In this method you can adjust your bean
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With