2

was trying micronaut with this example from there official website but got the following error.

Message: Entities not found for JPA configuration: 'default' within packages [example.micronaut]. Check that you have correctly specified a package containing JPA entities within the "jpa.default.entity-scan.packages" property in your application configuration and that those entities are either compiled with Micronaut or a build time index produced with @Introspected(packages="foo.bar", includedAnnotations=Entity.class) declared on your Application class Path Taken: SessionFactory.hibernateSessionFactory([SessionFactoryBuilder sessionFactoryBuilder]) --> SessionFactoryBuilder.hibernateSessionFactoryBuilder([MetadataSources metadataSources],ValidatorFactory validatorFactory,Interceptor hibernateInterceptor) io.micronaut.context.exceptions.BeanInstantiationException: Bean definition [org.hibernate.SessionFactory] could not be loaded: Error instantiating bean of type [org.hibernate.boot.SessionFactoryBuilder]

vijay pandey
  • 93
  • 1
  • 8

2 Answers2

0

You need to set property jpa.default.entity-scan.packages in application.yml.

For example, here you need to set

jpa.default.entity-scan.packages=example.micronaut.domain
  • It looks like, that the entity is not being found if Jakarta is used. import jakarta.persistence.Entity; @Entity – Fide Jul 25 '22 at 23:16
0

I found this in the docs - https://micronaut-projects.github.io/micronaut-data/latest/guide/#hibernateJpaAnnotations. So I guess that when using micronaut-data-jpa the annotations should be with javax.*

AchoVasilev
  • 454
  • 5
  • 15