• Register
0 votes
7.5k views

Problem :

I am developing the application in Spring, using a Tomcat, Mysql5, Java8... My problem is that I cannot deploy it, due to the "required bean 'entityManagerFactory' not found" problem. I have developed my project with the coworkers but they can perfectly deploy it without any problems and even if I copy-paste a same project in Spring Tool Suite I get below error. How it can be possible? Error as below :

***************************
APPLICATION FAILED TO START
***************************
Description:

Field usuarioDao in es.uc3m.tiw.Controladores.Controlador required a bean named 'entityManagerFactory' that could not be found.

Action:

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

 

3.9k points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

You must be missing the repository configuration, as you have to configure it using the @Repository,

Following code is incorrect,

public interface UsuarioRepository  extends JpaRepository<Usuario, Long> {

Rather it should be configured as the repository as below,

@Repository
public interface UsuarioRepository  extends JpaRepository<Usuario, Long> {

This code will make it the bean to be scanned and treat it as the repository and then your below code should work as expected by you,

@Autowired
private UsuarioRepository usuarioDao;

 OR

Check the persistence-api in your pom file and try to change it with hibernate-jpa-2.1 which is the part of spring-boot-started-data-jpa jar

38.6k points