Quando vou fazer a busca pelo nome ele lança essa exception
`
package br.com.alura.spring.data.service;
import java.util.List; import java.util.Scanner;
import org.springframework.stereotype.Service;
import br.com.alura.spring.data.orm.Funcionario; import br.com.alura.spring.data.repository.FuncionarioRepository;
@Service public class RelatoriosService { private Boolean system = true; private FuncionarioRepository funcionarioRepository;
public void inicial(Scanner scanner) {
while(system) {
System.out.println("Qual acao de cargo deseja executar");
System.out.println("0 - Sair");
System.out.println("1 - Buscar funcionario pelo nome");;
int action = scanner.nextInt();
switch (action) {
case 1:
buscarFuncionarioNome(scanner);
break;
default:
system = false;
break;
}
}
}
private void buscarFuncionarioNome(Scanner scanner) {
System.out.println("Qual o nome do funcionario: ");
String nome = scanner.nextLine().toUpperCase();
nome += scanner.nextLine().toUpperCase();
List<Funcionario> list = funcionarioRepository.findByNome(nome);
list.forEach(System.out::println);
}
}
SpringDataApplication
package br.com.alura.spring.data;
import java.util.Scanner;
import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import br.com.alura.spring.data.service.CrudCargoService; import br.com.alura.spring.data.service.CrudFuncionarioService; import br.com.alura.spring.data.service.CrudUnidadeTrabalhoService; import br.com.alura.spring.data.service.RelatoriosService;
@EnableJpaRepositories @SpringBootApplication public class SpringDataApplication implements CommandLineRunner {
private Boolean system = true;
private final CrudCargoService cargoService;
private final CrudFuncionarioService funcionarioService;
private final CrudUnidadeTrabalhoService unidadeTrabalhoService;
private final RelatoriosService relatoriosService;
public SpringDataApplication(CrudCargoService cargoService,
CrudFuncionarioService funcionarioService,
CrudUnidadeTrabalhoService unidadeTrabalhoService, RelatoriosService relatoriosService) {
this.cargoService = cargoService;
this.funcionarioService = funcionarioService;
this.unidadeTrabalhoService = unidadeTrabalhoService;
this.relatoriosService = relatoriosService;
}
public static void main(String[] args) {
SpringApplication.run(SpringDataApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
Scanner scanner = new Scanner(System.in);
while (system) {
System.out.println("Qual função deseja executar?");
System.out.println("0 - Sair");
System.out.println("1 - Cargo");
System.out.println("2 - Funcionario");
System.out.println("3 - Unidade");
System.out.println("4 - Relatorio");
Integer function = scanner.nextInt();
switch (function) {
case 1:
cargoService.inicial(scanner);
break;
case 2:
funcionarioService.inicial(scanner);
break;
case 3:
unidadeTrabalhoService.inicial(scanner);
break;
case 4:
relatoriosService.inicial(scanner);
break;
default:
System.out.println("Finalizando");
system = false;
break;
}
}
}
}
`