Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot 2.1 EntityManagerFactory Bean could not be found

I have simple Spring Boot project with JPA, Web and PostgreSQL. I'm using the latest Spring Boot version 2.1.3.RELEASE.

After adding simple JpaRepository application fails on startup with the following error:

***************************
APPLICATION FAILED TO START
***************************

Description:

Field dataMappingRepository in com.my.example.service.impl.SimpleServiceImpl required a bean named 'entityManagerFactory' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean named 'entityManagerFactory' in your configuration.

I have a simple @Service class like:

public class SimpleServiceImpl implements SimpleService {
  @Autowired private SimpleJpaRepository repo;
}

And JpaRepository:

public interface SimpleJpaRepository extends JpaRepository<SimpleEntity, Long> {}

And here is my application.yml:

spring:
   datasource:
      url: jdbc:postgresql://localhost:5432/simple
      username: user
      password: pass
      driver-class-name: org.postgresql.Driver
   jpa:
      show-sql: false
      properties:
         hibernate:
            dialect: org.hibernate.dialect.PostgreSQLDialect
      hibernate:
         ddl-auto: validate

If I change spring-boot-starter-parent to 2.0.8.RELEASE the application starts correctly.

like image 947
Danny Avatar asked Dec 04 '25 03:12

Danny


1 Answers

Ok, so finally the problem was as Andy Wilkinson said with cached Hibernate dependency.

After deleting org.hibernate folder from my M2 repo and updating maven project, it works correctly.

like image 191
Danny Avatar answered Dec 05 '25 19:12

Danny



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!