Olá pessoal! Meu código está pedindo o bean da classe/interface Repository... Já tentei usar @Autowired e nada...
***************************
APPLICATION FAILED TO START
***************************
Description:
Parameter 0 of constructor in br.com.spring.data.Application required a bean of type 'br.com.spring.repository.CargoRepository' that could not be found.
Action:
Consider defining a bean of type 'br.com.spring.repository.CargoRepository' in your configuration.
package br.com.spring.data;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import br.com.spring.data.model.Cargo;
import br.com.spring.repository.CargoRepository;
@SpringBootApplication
public class Application implements CommandLineRunner {
private CargoRepository repository;
public Application(CargoRepository repository) {
this.repository = repository;
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
public void run(String... args) throws Exception {
Cargo cargo = new Cargo();
cargo.setDescricao("DESENVOLVEDOR DE SOFTWARE");
repository.save(cargo);
}
}
package br.com.spring.data.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "cargos")
public class Cargo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String descricao;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
}
package br.com.spring.repository;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import br.com.spring.data.model.Cargo;
@Repository
public interface CargoRepository extends CrudRepository<Cargo, Integer>{
}