0

I have a model class like this

package student;

import java.util.UUID;

public class Student {
    
    private final UUID studentId;   
    private final String firstName;
    private final String lastName;
    private final String email;
    private final Gender gender;
    
    
    public Student(UUID studentId, String firstName, String lastName, String email, Gender gender) {
        super();
        this.studentId = studentId;
        this.firstName = firstName;
        this.lastName = lastName;
        this.email = email;
        this.gender = gender;
    }



    enum Gender {
        MALE, FEMALE
    }
}

I have RestController class like this

package student;

import java.util.List;
import java.util.UUID;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/students")
public class StudentController {

    @GetMapping
    public List<Student> getAllStudents() {
        return List.of(
                new Student(UUID.randomUUID(), "test", "test", "test", student.Student.Gender.MALE)
                );
    }

}

I am calling the endpoing with Postman like this:

enter image description here

And I am getting response like this

enter image description here

Please help me figure out what is causing the error

user9695260
  • 347
  • 3
  • 17
  • 1
    It doesn't return an empty list, 404 means it doesn't find your endpoint. WIthout knowing your configuration and seeing your`@SpringBootApplication` annotated class (and dependencies) this is impossible to answer. – M. Deinum Feb 28 '22 at 15:02
  • thanks, the problem was with the hierarchy of packages and classes – user9695260 Feb 28 '22 at 15:24

0 Answers0