0

我有一个 java suppler,它返回一个Studentpojo,如下所示:

    @Bean
    public Supplier<Date> studentSupplier() {
        return () -> new Student();
    }

现在我想让这个供应商Student在使用 api 创建条目后返回一个 pojo.. 像这样


    @RequestMapping(value = "/student",
        produces = { "application/json" }, 
        method = RequestMethod.POST)
    public ResponseEntity<Student> createStudent() {
        Student student = service.createStudent();
        return ResponseEntity.ok().body(student);
    }


    @Bean
    public Supplier<Student> studentSupplier() {
        return () -> {
        // How do I make this supplier return the Student pojo
        // created in above controller call? 
        };
    }


请注意我无法更改签名(例如更改Supplier为 a Function).. 供应商接口已插入我无法控制的外部系统

4

0 回答 0