Buenas tardes tengo el siguiente error en Spring boot al querer iniciar mi aplicación de ejemplo:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. [2m2020-11-19 17:09:22.045[0;39m [31mERROR[0;39m [35m12880[0;39m [2m---[0;39m [2m[ main][0;39m [36mo.s.boot.SpringApplication [0;39m [2m:[0;39m Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'categoriasRepository': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalArgumentException: Not a managed type: class model.Categoria
mi clase principal
package dbc.tienda;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import dbc.tienda.repository.categoriasRepository;
import model.Categoria;
@SpringBootApplication
public class TiendaDemoApplication implements CommandLineRunner{
@Autowired
private categoriasRepository repo;
public static void main(String[] args) {
SpringApplication.run(TiendaDemoApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
guardar();
}
private void guardar(){
Categoria cat =new Categoria();
cat.setTipo("mueble");
repo.save(cat);
System.out.println(cat);
}
}
mi clase Modelo
package model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name="categorias")
public class Categoria {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String tipo;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTipo() {
return tipo;
}
public void setTipo(String tipo) {
this.tipo = tipo;
}
@Override
public String toString() {
return "Categoria [id=" + id + ", tipo=" + tipo + "]";
}
}
Mi Interfaz repositorio de mi clase modelo
package dbc.tienda.repository;
import org.springframework.data.repository.CrudRepository;
import model.Categoria;
public interface categoriasRepository extends CrudRepository<Categoria, Integer> {
}
No entiendo el error. E seguido al pie de la letra el tutorial y no me falta nada.