Olá, pessoal, boa tarde.
Estou seguindo o curso e utilizando nomes diferentes para diferenciar um pouco o meu projeto, no entanto quando tento criar o repository da minha classe autor o projeto não compila e me é retornado o erro "Error creating bean with name 'autorController': Unsatisfied dependency expressed through field 'repository': Error creating bean with name 'autorRepository' defined in project.book.api.repository.AutorRepository defined in @EnableJpaRepositories declared on JpaRepositoriesRegistrar.EnableJpaRepositoriesConfiguration: Not a managed type: class project.book.api.model.DadosCadastroAutor"
Aguem pode me ajudar, por favor?
Classe AutorController
package project.book.api.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import project.book.api.model.AutorModel;
import project.book.api.model.DadosCadastroAutor;
import project.book.api.repository.AutorRepository;
@RestController
@RequestMapping("autor")
public class AutorController {
@Autowired
private AutorRepository repository;
@PostMapping
public void cadastrar(@RequestBody DadosCadastroAutor json) {
repository.save(new AutorModel(json));
}
}
AutorRepository
package project.book.api.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import project.book.api.model.AutorModel;
import project.book.api.model.DadosCadastroAutor;
public interface AutorRepository extends JpaRepository<DadosCadastroAutor, Long>{
//void save(AutorModel autorModel);
}
DadosCadastroAutor
package project.book.api.model;
import java.util.Date;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
public record DadosCadastroAutor(String nome, String idade){
}