1

Using: Spring Boot Maven Lombok STS 4.9

I have a simple constructor which takes in 3 arguments and assigns them each to a corresponding field. Another field is auto-generated, and two more are autowired by Spring. The constructor, which is explicitly defined, is annotated with @Builder (at the constructor level, as Lombok recommends in the documentation.) the constructor looks like so:

    @Id
    @GeneratedValue( )
    @Column(value="account_id")
    private Long accountId;
    
    @Setter
    @Column(value="user_id")
    @ManyToOne
    private Long userId;
    
    @Setter
    @Column(value="credentials")
    @OneToOne
    @PrimaryKeyJoinColumn(name="accountId")
    private Credentials credentials;
    
    @Setter
    @Column(value="user_profile")
    @OneToOne
    @PrimaryKeyJoinColumn(name="accountId")
    private UserProfileInfo userProfileInfo;
    
    @Setter
    @Column(value="account_credit")
    @OneToOne
    @PrimaryKeyJoinColumn(name="accountId")
    @Autowired
    private Credit acctCredit;
    
    @Column(value="account_state")
    @OneToOne
    @PrimaryKeyJoinColumn(name="accountId")
    @Autowired
    private AccountState acctState;
    
    
    
    @Builder
    public Account(Long userId, Credentials cred, UserProfileInfo info){
        this.userId = userId;
        this.credentials = cred;
        this.userProfileInfo = info;    
    }

As far as I can see, everything seems to check out here.At the very least, there are no warnings or errors. However, when I try to use the builder() method elsewhere, as is shown here:

    @Test
    void testThreeArgConstructerReturnsProperObject() {
        
        Account testAccount = Account.builder().build();
        
    }

...it is as if the @Builder method wasn't there at all. I get the usual red underline under build, but hovering w/ cursor just gives the option to declare a new builder() in Account class. If I delete builder() from the test class, intellisense just shows Account.class, super, and this . It is as if the annotation wasn't there.

At first, I thought that I had misused it somehow, as I just recently started using it, But I have been looking over my code and comparing with examples for hours now. As far as I can tell, syntax and usage are correct.

I have done a bit of debugging as well. Aside from checking intellisense, I have also tried using it at different scopes, including in the same package, and I tried the "simplest form" method, where I changed the method so it only has a single int parameter. In every case, I couldnt get the environment to acknowledge the constructor.

Am I overlooking something here?

Nate T
  • 727
  • 5
  • 21
  • If there is any info that I left out pls let me know and I'll post it. I can post the composing classes as well, but I don't think they are related. And they are all pretty large. – Nate T Jun 06 '21 at 11:21
  • 1
    do the other lombok annotations provide generate what you expect them to? – Stultuske Jun 06 '21 at 11:30
  • not sure, I will try to test. I don't think I am using any others at the moment. I will try a couple in a test. – Nate T Jun 06 '21 at 11:38
  • @Stultuske No they aren't. I brought Lombok into maven via Initializr when I created the project. I know that I've got the jar, the annotations are autoimporting on hover+click. Not sure why they aren't working. – Nate T Jun 06 '21 at 11:50
  • Just confirmed. 1.18.20.jar is on the build path. I don't think Maven has a version specified. – Nate T Jun 06 '21 at 11:52
  • I was facing similar issue when I tried to reproduce issue mentioned by you on my computer. I have done following- 1. setup lombok for my Eclipse IDE. 2. Restarted Eclipse IDE. and It worked. :) There might be some issues with your lombok setup. I have done setup using information provided at https://www.baeldung.com/lombok-ide – pcsutar Jun 06 '21 at 15:04
  • Thank you for the advice. I reinstalIed Lombok through the Eclipse marketplace about an hour ago but no dice. I think something is corrupted in my sts installation. I am on Linux, so I had to build from a tarball, and I noticed that every time I open sts, even immediately after reboot, the fan starts going at full speed and doesn't stop until after I quit sts. Its never done this before today. There used to be an option to give eclipse more memory, but I can't find it now. Did they get rid of the setting or am I overlooking it? Thanks again – Nate T Jun 06 '21 at 15:21

1 Answers1

0

I finally figured it out! The reason that Lombok wasn't working was due to my pc. I haven't used it since switching to PC. Apparently, Lombok doesn't like STS on linux. in order to get it working I had to install manually through a process for which instructions aren't easily located, and which I ultimately found here.

Nate T
  • 727
  • 5
  • 21
  • I would also like to change the title to better reflect the issue. I will leave the question untouched so as not to distort the original context. I just don't want anyone else to go through this process. I started this journey at about 5 am, and I am just now finishing... 3 pm – Nate T Jun 06 '21 at 19:01