Spring Framework - DirectFieldAccessor Examples

Spring Framework 

DirectFieldAccessor can be used to read and write fields without setters and getters.

package com.logicbig.example.directfieldAccessor;

import org.springframework.beans.DirectFieldAccessor;

public class DirectFieldAccessorExample {

public static void main (String[] args) {
DirectFieldAccessor a = new DirectFieldAccessor(new LocalBean());
a.setPropertyValue("str", "setting a direct value");

private static class LocalBean {
private String str;

public String toString () {
return "LocalBean{" +
"str='" + str + '\'' +


LocalBean{str='setting a direct value'}
Original Post

See Also