Update object private property with groovy

You can update private field an object with below sample code.

def myBean = spring.getBean("myBean");

def f = myBean.getClass().getDeclaredField("myField");
f.setAccessible(true);
f.set(myBean, "new string value");

Bir Cevap Bırakın

XHTML: Şu etiketleri kullanabilirsiniz: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>