Spring newbie here. Three classes
Employee.java
package com.example.model;
public class Employee {
private int employeeId;
private String name;
private String email;
public Employee(int employeeId, String name, String email)
{
this.setEmployeeId(employeeId);
this.setName(name);
this.setEmail(email);
}
public int getEmployeeId() {
return employeeId;
}
public void setEmployeeId(int employeeId) {
this.employeeId = employeeId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
EmployeeDao.java
@Component
public class EmployeeDao {
static List<Employee> list = new ArrayList<>();
static
{
list.add(new Employee(1234,"Nancy", "nancy@mail.com"));
list.add(new Employee(5678, "Daniel","daniel@mail.com"));
list.add(new Employee(9101, "Scott", "scott@mail.com"));
}
public List<Employee> getAllEmployees()
{
return list;
}
}
EmployeeController.java
@RestController
public class EmployeeController {
@Autowired
EmployeeDao service;
@GetMapping(path = "/employees")
public List<Employee> getAll()
{
System.out.println(service.getAllEmployees());
return service.getAllEmployees();
}
}
Postman execution of GET employees throws up this error(404)
Project Setup