Skip to content

Problem with multiple @EnableJpaRepositories - "Not a managed type" exception when running with AOT #4105

@hendrik-frahmann-nmc

Description

@hendrik-frahmann-nmc

I have a Spring Boot 4 project with multiple @EnableJpaRepositories configurations.
When I run the application without AOT it's working fine.
But if I package it with AOT and execute it with AOT enabled I get this exception:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'secondRepository': Not a managed type: class org.example.second.SecondEntity
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1817) ~[spring-beans-7.0.1.jar:7.0.1]
	...
Caused by: java.lang.IllegalArgumentException: Not a managed type: class org.example.second.SecondEntity
	at org.hibernate.metamodel.model.domain.internal.JpaMetamodelImpl.managedType(JpaMetamodelImpl.java:247) ~[hibernate-core-7.1.8.Final.jar:7.1.8.Final]
	at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:413) ~[hibernate-core-7.1.8.Final.jar:7.1.8.Final]
	at org.hibernate.metamodel.model.domain.internal.MappingMetamodelImpl.managedType(MappingMetamodelImpl.java:88) ~[hibernate-core-7.1.8.Final.jar:7.1.8.Final]

Demo Project:
If you just change the Spring Boot Version in this project to 3.5.8 it's working, but not with 4.0.0.

https://github.com/hendrik-frahmann-nmc/spring-boot-4-multi-jpa-demo

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions