title: Builder Annotation not working in Java class
body: <hr>
  
  <p>This code was written for learnig purpose.
  @Builder and @Data annotation has been implemented in the Book class. While trying to create a builder for the same in LibraryApplication.java builder is not being recognized. </p>
  
  <p>How can I enable the annotations which on Book class</p>
  
  <p>**Edit **: When trying to compile below error is generated.<br>
        java.lang.Error: Unresolved compilation problem: The method builder() is undefined for the type Book at com.baeldung.LibraryApplication$DataSetup.run(LibraryApplication.java:25) </p>
  
  <p>Also I am using STS implementation of eclipse. I have checked whether the same code works in eclilpse Oxygen but the same error is thrown</p>
  
  <p>Note: The project is created in Spring Boot</p>
  
  <p>Book.class</p>
  
  <pre><code>package com.baeldung.domain;
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.Id;
  import javax.validation.constraints.NotNull;
  
  import lombok.AllArgsConstructor;
  import lombok.Builder;
  import lombok.Data;
  import lombok.NoArgsConstructor;
  
  
  @Data
  @NoArgsConstructor
  @Builder
  @Entity
  @AllArgsConstructor
  public class Book {
  
  @Id
  @GeneratedValue
  private Long id;
  
  @NotNull
  String name, isbn;
  
  }
  </code></pre>
  
  <p>LibraryApplication.java</p>
  
  <pre><code>package com.baeldung;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.ApplicationArguments;
  import org.springframework.boot.ApplicationRunner;
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.stereotype.Component;
  
  import com.baeldung.domain.Book;
  import com.baeldung.repo.BookingRespository;
  
  @SpringBootApplication
  public class LibraryApplication {
  
  @Autowired
  private BookingRespository bookingRespository;
  
  @Component
  class DataSetup implements ApplicationRunner{
  
      @Override
      public void run(ApplicationArguments args) throws Exception {
  //             bookingRespository.save(Book.builder().name("Way of Kings").isbn("123").build());
  
      }
  
  }
  
  public static void main(String[] args) {
      SpringApplication.run(LibraryApplication.class, args);
  }
  
  }
  </code></pre>
  
  <p>BookingRepository.java</p>
  
  <pre><code>package com.baeldung.repo;
  
  import org.springframework.data.repository.PagingAndSortingRepository;
  import org.springframework.data.rest.core.annotation.RepositoryRestResource;
  
  import com.baeldung.domain.Book;
  
  @RepositoryRestResource(path="books",collectionResourceRel="books")
  public interface BookingRespository extends PagingAndSortingRepository&lt;Book, Long&gt;{
  
  }
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"&gt;
  &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
  &lt;parent&gt;
      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
      &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
      &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;
      &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
  &lt;/parent&gt;
  &lt;groupId&gt;com.baeldung&lt;/groupId&gt;
  &lt;artifactId&gt;library&lt;/artifactId&gt;
  &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;library&lt;/name&gt;
  &lt;description&gt;Demo project for Spring Boot&lt;/description&gt;
  
  &lt;properties&gt;
      &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-jpa&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-data-rest&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-validation&lt;/artifactId&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-devtools&lt;/artifactId&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.h2database&lt;/groupId&gt;
          &lt;artifactId&gt;h2&lt;/artifactId&gt;
          &lt;scope&gt;runtime&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
          &lt;artifactId&gt;lombok&lt;/artifactId&gt;
          &lt;optional&gt;true&lt;/optional&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
          &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;
          &lt;scope&gt;test&lt;/scope&gt;
          &lt;exclusions&gt;
              &lt;exclusion&gt;
                  &lt;groupId&gt;org.assertj&lt;/groupId&gt;
                  &lt;artifactId&gt;assertj-core&lt;/artifactId&gt;
              &lt;/exclusion&gt;
          &lt;/exclusions&gt;
      &lt;/dependency&gt;
  
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.guava&lt;/groupId&gt;
          &lt;artifactId&gt;guava&lt;/artifactId&gt;
          &lt;version&gt;27.0.1-jre&lt;/version&gt;
      &lt;/dependency&gt;
  
  
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p></p>