Untitled

produces this error when accessed at localhost:8080 No serializer found for class com.example.demo.Student and no properties discovered to create BeanSerializer
 avatar
unknown
java
2 years ago
884 B
3
Indexable
// DemoApplication.java

package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@SpringBootApplication
@RestController
public class DemoApplication {

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

	@GetMapping("/")
	public List<Student> hello() {
		return List.of(new Student("hello"));
	}
}



// Student.java
package com.example.demo;

import java.io.Serializable;

public class Student implements Serializable {
    private String message;

    public Student() {
    }

    public Student(String message) {
        this.message = message;
    }
}
Editor is loading...