小编nar*_*007的帖子

如何在 Spring Boot 中返回响应但继续执行循环?

因此,当我访问 enpoint(POST 请求)时,我首先检查数据库中是否已存在条目。如果是,我想将其返回给用户(用于跟踪目的)并继续操作。但我想将 id 返回给用户并继续此过程。如何实现这一目标?

@RestController
public class StudentController {
    @Autowired
    private StudentService service;

    @PostMapping("/storeInDB")
    @ResponseBody
    public File_Tracking saveStudentDetails(@RequestBody Student student ) throws IOException {

        List<Students> student = new ArrayList<>();


        int continue = 0;
        int id = 0;


            id = service.getId(); // I want to return this and continue some other process which follows

Run Code Online (Sandbox Code Playgroud)

java asynchronous spring-boot

4
推荐指数
1
解决办法
1万
查看次数

Spring Boot 单元测试建议。?

我有一个控制器类和一个服务类。控制器具有端点,服务层具有执行特定操作的功能(插入、加载文件和计算行数、更新等)。

现在我想知道的是,我应该将端点(控制器)作为整体还是服务层中存在的单个功能进行单元测试?我真的很困惑。请帮忙。

java junit spring-boot

2
推荐指数
1
解决办法
46
查看次数

标签 统计

java ×2

spring-boot ×2

asynchronous ×1

junit ×1