title: error creating repository - Not a managed type when springboot with h2
body: <p>I get the above error even after introducing the entity scan. I will add my code below.</p>
  <p>main class</p>
  <pre><code>package com.idealo.demoapp1;
  
  import org.springframework.boot.SpringApplication;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.autoconfigure.domain.EntityScan;
  import org.springframework.context.annotation.ComponentScan;
  import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
  import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  
  
  @SpringBootApplication
  //@EnableJpaAuditing
  @EnableJpaRepositories(&quot;com.idealo.demoapp1.repository&quot;)
  @EntityScan(&quot;com.idealo.demoapp1.entity&quot;)
  @ComponentScan(&quot;com.*&quot;)
  public class DemoApp1Application {
  
  public static void main(String[] args) {
      SpringApplication.run(DemoApp1Application.class, args);
   }
  }
  </code></pre>
  <p>controller</p>
  <pre><code>package com.idealo.demoapp1.controller;
  
  import com.idealo.demoapp1.entity.Item;
  //import org.glassfish.jaxb.runtime.v2.schemagen.xmlschema.List;
  import com.idealo.demoapp1.service.ItemService;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.GetMapping;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.ResponseBody;
  
  import java.util.List;
  
  @Controller
  @RequestMapping(path = &quot;/item&quot;)
  public class ItemController {
  
  //    @Autowired
      ItemService itemService;
      
      @GetMapping
      @ResponseBody
      public List&lt;Item&gt; getAllItems() {
           return itemService.getAllItems();
      }
  }
  </code></pre>
  <p>service</p>
  <pre><code>package com.idealo.demoapp1.service;
  
  import com.idealo.demoapp1.entity.Item;
  import com.idealo.demoapp1.repository.ItemRepository;
  import lombok.RequiredArgsConstructor;
  import org.springframework.stereotype.Service;
  import org.springframework.transaction.annotation.Transactional;
  
  import java.util.List;
  
  @RequiredArgsConstructor
  @Service
  @Transactional
  public class ItemService {
  
  //    @Autowired
      ItemRepository itemRepository;
  
      public List&lt;Item&gt; getAllItems() {
          return itemRepository.findAll();
      }
  
  }
  </code></pre>
  <p>repository</p>
  <pre><code>package com.idealo.demoapp1.repository;
  
  import com.idealo.demoapp1.entity.Item;
  import org.springframework.data.jpa.repository.JpaRepository;
  import org.springframework.stereotype.Repository;
  
  import java.util.UUID;
  
  @Repository
  public interface ItemRepository extends JpaRepository&lt;Item, UUID&gt; {
  
  }
  </code></pre>
  <p>entity</p>
  <pre><code>package com.idealo.demoapp1.entity;
  
  import com.sun.istack.NotNull;
  import lombok.AllArgsConstructor;
  import lombok.Builder;
  import lombok.Data;
  import lombok.NoArgsConstructor;
  import org.springframework.data.annotation.CreatedDate;
  import org.springframework.data.annotation.LastModifiedDate;
  import org.springframework.data.jpa.domain.support.AuditingEntityListener;
  
  import javax.persistence.*;
  import java.util.UUID;
  
  @Entity
  @Table(name = &quot;item&quot;)
  @NoArgsConstructor
  @AllArgsConstructor
  @Data
  @Builder
  @EntityListeners(AuditingEntityListener.class)
  public class Item {
      
      @Id
      private UUID id;
  
      @Column
      private String product_name;
  
      @Column
      private String producer;
  
      @Column
      private String product_desc;
  
      @Column
      private String product_picture;
  
      @Column
      private String current_price;
  
      @Column
      private String best_price;
  
      @Column
      private String best_price_date;
  
      @Column
      private String product_rating;
      
  }
  </code></pre>
  <p>h2 configs in application.properties</p>
  <pre><code>server.servlet.context-path=/${spring.application.name}
  spring.h2.console.enabled=true
  spring.h2.console.path=/h2-console
  spring.datasource.driver-class-name=org.h2.Driver
  spring.datasource.url=jdbc:h2:mem:idealo;TRACE_LEVEL_FILE=4
  spring.datasource.username=idealo
  spring.datasource.password=123
  spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true
  spring.jpa.hibernate.ddl-auto=create-drop
  spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
  spring.jpa.open-in-view=true
  spring.application.name=idealo-backend
  logging.level.org.hibernate.SQL=DEBUG
  </code></pre>
  <p>error</p>
  <pre><code>Error creating bean with name 'itemRepository' defined in com.idealo.demoapp1.repository.ItemRepository defined in @EnableJpaRepositories declared on DemoApp1Application: Not a managed type: class com.idealo.demoapp1.entity.Item
  </code></pre>
  <p>Folder structure</p>
  <p><a href="https://i.stack.imgur.com/W43fT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/W43fT.png" alt="enter image description here" /></a></p>
  <p>pom</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
      xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&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;3.0.0-SNAPSHOT&lt;/version&gt;
          &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;
      &lt;/parent&gt;
      &lt;groupId&gt;com.idealo&lt;/groupId&gt;
      &lt;artifactId&gt;demo-app1&lt;/artifactId&gt;
      &lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
      &lt;packaging&gt;war&lt;/packaging&gt;
      &lt;name&gt;demo-app1&lt;/name&gt;
      &lt;description&gt;Demo project with Spring Boot for idealo&lt;/description&gt;
      &lt;properties&gt;
          &lt;java.version&gt;1.8&lt;/java.version&gt;
  &lt;!--        &lt;maven.compiler.release&gt;8&lt;/maven.compiler.release&gt;--&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-web&lt;/artifactId&gt;
          &lt;/dependency&gt;
          &lt;!-- https://mvnrepository.com/artifact/javax.persistence/javax.persistence-api --&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;javax.persistence&lt;/groupId&gt;
              &lt;artifactId&gt;javax.persistence-api&lt;/artifactId&gt;
              &lt;version&gt;2.2&lt;/version&gt;
          &lt;/dependency&gt;
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.projectlombok&lt;/groupId&gt;
              &lt;artifactId&gt;lombok&lt;/artifactId&gt;
              &lt;version&gt;1.18.24&lt;/version&gt;
              &lt;scope&gt;provided&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;com.cedarsoftware&lt;/groupId&gt;
              &lt;artifactId&gt;java-util&lt;/artifactId&gt;
              &lt;version&gt;1.8.0&lt;/version&gt;
          &lt;/dependency&gt;
  
  &lt;!--        &lt;dependency&gt;--&gt;
  &lt;!--            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;--&gt;
  &lt;!--            &lt;artifactId&gt;spring-boot-starter-jdbc&lt;/artifactId&gt;--&gt;
  &lt;!--        &lt;/dependency&gt;--&gt;
  
  
  
  
          &lt;dependency&gt;
              &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
              &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;
              &lt;scope&gt;provided&lt;/scope&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;/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;/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;
      &lt;repositories&gt;
          &lt;repository&gt;
              &lt;id&gt;spring-milestones&lt;/id&gt;
              &lt;name&gt;Spring Milestones&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/milestone&lt;/url&gt;
              &lt;snapshots&gt;
                  &lt;enabled&gt;false&lt;/enabled&gt;
              &lt;/snapshots&gt;
          &lt;/repository&gt;
          &lt;repository&gt;
              &lt;id&gt;spring-snapshots&lt;/id&gt;
              &lt;name&gt;Spring Snapshots&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/snapshot&lt;/url&gt;
              &lt;releases&gt;
                  &lt;enabled&gt;false&lt;/enabled&gt;
              &lt;/releases&gt;
          &lt;/repository&gt;
      &lt;/repositories&gt;
      &lt;pluginRepositories&gt;
          &lt;pluginRepository&gt;
              &lt;id&gt;spring-milestones&lt;/id&gt;
              &lt;name&gt;Spring Milestones&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/milestone&lt;/url&gt;
              &lt;snapshots&gt;
                  &lt;enabled&gt;false&lt;/enabled&gt;
              &lt;/snapshots&gt;
          &lt;/pluginRepository&gt;
          &lt;pluginRepository&gt;
              &lt;id&gt;spring-snapshots&lt;/id&gt;
              &lt;name&gt;Spring Snapshots&lt;/name&gt;
              &lt;url&gt;https://repo.spring.io/snapshot&lt;/url&gt;
              &lt;releases&gt;
                  &lt;enabled&gt;false&lt;/enabled&gt;
              &lt;/releases&gt;
          &lt;/pluginRepository&gt;
      &lt;/pluginRepositories&gt;
  
  &lt;/project&gt;
  </code></pre>
  <p>I have gone through similar questions and have tried the solutions without success.
  I greatly appreciate if someone can assist me in finding the root cause for this issue</p>