I have a bean BeanA with injected property private int url
:
class BeanA { @Value(${"db.url"}) private String url; private DbConnection connection; }
Let us say this Value
annotation is similar to Spring Value
. During initialization, connection will be initialized by using injected property into url field. And also there is some PostConstruct and PreDestroy
methods in BeanA
.
My question is: is it possible to dynamically reinstantiate BeanA
when url
property changed. I have mechanism of detecting property change. For now, I just re-inject this url only, but I want to recreate this bean, initialize new connection and re-inject this bean in all dependetn beans. I dont use Spring Cloud Config.