How to Access Setter Method

647 views
Skip to first unread message

Eric H

unread,
Aug 28, 2018, 11:21:35 AM8/28/18
to Project Lombok
Hi,

I've created a POJO and used the @Getter and @Setter annotation to generate the getters and setters. I now want to call one of the setter methods but the code does not recognize the method.  The error says "method is unrecognized".  

How do you access a setter using Lombok from another class?

POJO:

@ToString
public class Person implements Serializable {

/**
*/
private static final long serialVersionUID = -7748826653062256252L;
private @Getter @Setter String cn;
private @Getter @Setter List<String> groupMembership;
private @Getter @Setter boolean isEmployee;
}



Calling code:

public Person getUserPerson(HttpServletRequest request) {
Person userPerson = new Person();
userPerson.setCn("test");
return userPerson;
}


Mehmet Gunacti

unread,
Aug 28, 2018, 12:10:43 PM8/28/18
to project...@googlegroups.com
Try a "clean" on your project. That might solve it.

--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Eric H

unread,
Aug 28, 2018, 3:43:37 PM8/28/18
to Project Lombok
Hi,

Thanks for the response.  I tried a clean and it did not get rid of the error.  I tried a regular project clean as well as a maven clean.  I'm using Eclipse.

Nick Stolwijk

unread,
Aug 28, 2018, 6:18:52 PM8/28/18
to project...@googlegroups.com
I don't know for sure if it is still necessary if you are using Maven and Eclipse. Did you use M2Eclipse to import the project or the Maven-Eclipse-plugin? I guess the second and then you need to install the Lombok plugin in Eclipse [1]


Hth,

Nick Stolwijk

~~~ Try to leave this world a little better than you found it and, when your turn comes to die, you can die happy in feeling that at any rate you have not wasted your time but have done your best ~~~

Lord Baden-Powell

Reinier Zwitserloot

unread,
Aug 29, 2018, 9:22:46 PM8/29/18
to Project Lombok
You have to double click the lombok jar to install it into your eclipse; see the video on projectlombok.org. You can verify this installation has been succesful by opening your eclipse 'about' box; the last line should mention lombok. If it doesn't, that step didn't work or hasn't been done.
Reply all
Reply to author
Forward
0 new messages