Search code examples
javaspring-bootlomboksts

Lombok not working in self installed STS on Linux -- Why are my constructors not recognizing the @Builder annotation


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?


Solution

  • 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.