Whitelabel Error Page

Asked

Viewed 844 times

0

Hello, I am trying to make a spring boot application with access to mysql database using Jdbctemplate and when I try to access via url the database data always returns me the error:

Whitelabel Error Page
This application has no Explicit Mapping for /error, so you are Seeing this as a fallback. Mon Dec 19 12:32:45 BRST 2016 There was an Unexpected error (type=Not Found, status=404). No message available

Estrutura do projeto

Staff Class

public class Funcionario implements Serializable{
private static final long serialVersionUID = 1L;

private Integer codigo;
private String nome;
private String cargo;
private Integer idade;

private Departamento departamento;

public Funcionario() {
    super();
}
//getter e setters omitidos

Challenge 2application.java

@SpringBootApplication
public class Desafio2Application {

public static void main(String[] args) {
    SpringApplication.run(Desafio2Application.class, args);
}
}

Servletinitializer

public class ServletInitializer extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder    application) {
    return application.sources(Desafio2Application.class);
}

}

Functionaoimpl

@Repository
public class FuncionarioDaoImpl implements FuncionarioDao{

@Autowired
private JdbcTemplate JdbcTemplate;
@Override
public List<Map<String, Object>> findAll() {
    return JdbcTemplate.queryForList("select * from Funcionario");
}
}

Functioncontroller

@RestController
public class FuncionarioController {
@Autowired
FuncionarioService funcionarioService;

@RequestMapping("/funcionarios")
public List<Map<String, Object>> findAll(){
    return funcionarioService.findAll();
}
}

Employee

@Service
public class FuncionarioServiceImpl implements FuncionarioService{

@Autowired
private FuncionarioDao funcionarioDao;

@Override
public List<Map<String, Object>> findAll() {
    return this.funcionarioDao.findAll();
}
}

I’m starting now with Spring and I don’t have much experience... I already looked for some solutions but I couldn’t solve the problem that is to show on the screen via url the list of employees.. Thanks in advance

  • Which url you are trying to access?

  • In the application.properties you can set the context and port.

  • In the application.properties add these 2 properties: server.contextPath=/test server.port=9080 Page path: ... src main webapp login.xhtml The url would look like: http://localhost:9080/test/login.xhtml

  • The url would be localhost:8080/employees. I was able to solve the problem that in a reorganization of the project structure spring managed to map the url.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.