Spring Data Jpa- No Bean Named 'Entitymanagerfactory' Is Defined; Injection of Autowired Dependencies Failed

Spring data jpa- No bean named 'entityManagerFactory' is defined; Injection of autowired dependencies failed

Spring Data JPA by default looks for an EntityManagerFactory named entityManagerFactory. Check out this part of the Javadoc of EnableJpaRepositories or Table 2.1 of the Spring Data JPA documentation.

That means that you either have to rename your emf bean to entityManagerFactory or change your Spring configuration to:

<jpa:repositories base-package="your.package" entity-manager-factory-ref="emf" /> 

(if you are using XML)

or

@EnableJpaRepositories(basePackages="your.package", entityManagerFactoryRef="emf")

(if you are using Java Config)

Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException

I add this dependency and I solved.

<!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>


Related Topics



Leave a reply



Submit