Jeff
Jeff

Reputation: 8411

Lombok does not add the methods

To make a model for my application, I did the following:

1-I added the following dependencies to the Pom.xml

        <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-data-jpa</artifactId> 
        </dependency>
        <dependency>
          <groupId>com.h2database</groupId>
          <artifactId>h2</artifactId> 
        </dependency>
        <dependency>
          <groupId>org.projectlombok</groupId>
          <artifactId>lombok</artifactId> 
          <version>1.16.6</version>
        </dependency>

2- I made a model like this code:

 import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import lombok.Data;

@Entity
@Data
public class Plant {
  @Id
  @GeneratedValue
  Long id;

  String name;
  String description;
  @Column(precision=8, scale=2)
  BigDecimal price;
}

I expect by saving the model file it automatically generates some setter/getter methods for Plant class, but it doesn't happen. How can I fix the problem?

Upvotes: 1

Views: 319

Answers (1)

Jeff
Jeff

Reputation: 3882

Since STS is Eclipse based you need to run the Eclipse installation procedure explained here.

Also Lombok should be declared as a provided dependency.

  <groupId>org.projectlombok<groupId>
  <artifactId>lombok</artifactId>
  <version>1.16.6</version>
  <scope>provided</scope>

Upvotes: 2

Related Questions