Spring Data JPA - Consider Defining a Bean Named 'Entitymanagerfactory' in Your Configuration

Java Spring Boot: Consider defining a bean named 'entityManagerFactory' in your configuration

Well, after 17 days finally I got the solution:

my problem was on properties file, for some reason I used this line (I can't remember why):
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

I just commented it and problem solved.

Lessons learned:

  1. always document your code
  2. JitterTed's discord is a great source of answers.

Spring Boot: Consider defining a bean named 'entityManagerFactory' in your configuration

In spring-boot, you don't need to annotate your repository class with the repository annotation.

@Repository

You just need to extend JPARepository on your interface and Spring-boot will take care of the rest.
For Example:

public interface YourRepository extends JpaRepository<YourDomain, Serializable> {

YourDomain findBysomeparameter(Long parameter);

}

And you don't need to add these annotations:

@EnableJpaRepositories
@EntityScan
@ComponentScan

Spring-boot does that automatically unless you're doing some configuration.

I hope this will help.



Related Topics



Leave a reply



Submit