Galera, faz horas que eu estou tentando resolver um problema no meu Spring data JPA Executo o cógido e recebo esse erro
Description:
Parameter 0 of constructor in br.com.aluguel.de.carros.alugador.AlugadorServiceImpl 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.
Como se o construtor do meu AlugadorServiceImpl estivesse 0, mas não está!! Já procurei em todo lugar na internet, fala pra adicionar umas dependencias no meu pom.xml, eu adiciono e o erro persiste
O meu AlugadorServiceImpl esta assim:
package br.com.aluguel.de.carros.alugador;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class AlugadorServiceImpl implements AlugadorService {
private AlugadorRepository repository;
@Autowired
public AlugadorServiceImpl(AlugadorRepository repository) {
this.repository = repository;
}
@Override
public List<Alugador> todos() {
return repository.findAll();
}
@Override
public Optional<Alugador> alugador(Long id) {
return repository.findById(id);
}
@Override
public Alugador novo(Alugador alugador) {
alugador.setNome(alugador.getNome());
return repository.save(alugador);
}
@Override
public Alugador atualiza(Alugador alugador) {
Alugador alugadorAtualizado = repository.save(alugador);
//repository.reflesh(alugadorAtualizado);
return alugadorAtualizado;
}
@Override
public boolean deleta(Long id) {
Optional<Alugador> alugadorOpt = alugador(id);
if (alugadorOpt.isPresent()) {
repository.delete(alugadorOpt.get());
return true;
}
return false;
}
}
Meu pom.xlm esta assim:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>br.com.tmf</groupId>
<artifactId>gp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>gp</name>
<description>WebApp Para gerenciar projetos</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.0.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.3.Final</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>5.1.9.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
Meu AlugadorService esta assim:
package br.com.aluguel.de.carros.alugador;
import java.util.List;
import java.util.Optional;
public interface AlugadorService {
List<Alugador> todos();
Optional<Alugador> alugador(Long id);
Alugador novo(Alugador alugador);
Alugador atualiza(Alugador alugador);
boolean deleta(Long id);
}
E meu AlugadorRepository esta assim:
package br.com.aluguel.de.carros.alugador;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface AlugadorRepository extends JpaRepository<Alugador, Long> {
}
Alguem me ajude por favor, já não sei mais o que fazer