Refresh Spring prototype bean properties with Spring Cloud Config refresh -
i have prototype bean want properties (annotated @value
) refreshed when spring cloud config /refresh endpoint triggered.
do prototype beans external config properties refreshed automatically? or still need marked @refreshscope
live in 'refresh' scope cache , invalidated other bean?
background:
i've been using @refreshscope
on other, singleton beans fine , had attempted put annotation on prototype bean that's caused problems existing code , unit tests instantiate bean via appcontext.getbean("beanname", constructorargs)
, cast returned object expected bean type. @refreshscope
adds proxy in mix causes classcastexception
existing code. i've tried working around adding interface that's led more trouble within unit test calls methods directly in bean shouldn't , hoping not pull methods interface.
but dawned on me maybe prototype beans automatically properties refreshed via spring cloud config on use of them since instantiated every time.
i've read thru spring cloud doc , searched here couldn't find calling out prototype beans in manner. maybe wishful thinking.
Comments
Post a Comment