I'm getting below error while running my Springboot application
Error creating bean with name 'userRepo' defined in defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Cannot resolve reference to bean 'jpaSharedEM_entityManagerFactory' while setting bean property 'entityManager'
package <mypackage>;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserRepo extends JpaRepository<User,Long>{
Optional<User> findByEmail(String email);
}
I'm using Java 17
, Spring-boot 3.1.2
, spring-boot-starter-data-jpa
and spring-boot-starter-security
I've tried to check if my database server is running & correctly configured in application.properties
file but i've not found any problem there
I also encountered this issue when I tried to upgrade from Springboot 2.x.x to 3.x.x. Finally figured out it is due to wrongly defined naming strategy. In my case I updated below line in my application.yml file and solved the issue.
Previously I had
physicalNamingStrategy: org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
Then I changed it to
physicalNamingStrategy: org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With