V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
iv8d
V2EX  ›  JetBrains

关于 idea 调试关闭时操作

  •  
  •   iv8d · 1 天前 · 468 次点击

    ##需求 在 idea 调试 spring 代码时,需要调试在服务关闭时进行的操作,目前 debug 模式下直接点关闭服务,能进入 ContextClosedEvent 代码,但是只能显示日志,无法停到在此处设置的断点中。

    ##目标 希望能在服务关闭时跟进断点内

    7 条回复    2026-01-06 14:59:26 +08:00
    iv8d
        1
    iv8d  
    OP
       1 天前
    帖子沉这么快吗
    twofox
        2
    twofox  
       1 天前
    没做过类似的场景
    yooomu
        3
    yooomu  
       1 天前 via iPhone
    SpringApplication.exit() ,写个接口或者定时任务,调用这个方法,自己关闭自己就能断点了
    acrisliu
        4
    acrisliu  
       1 天前
    写个借口调用 3 楼的方法
    acrisliu
        5
    acrisliu  
       1 天前
    @acrisliu 借口 ➡️ 接口
    iv8d
        6
    iv8d  
    OP
       1 天前
    SpringApplication.exit 是主动退出吧,有没有那种点 idea 上的 stop 按钮停止的 debug 呢。
    iv8d
        7
    iv8d  
    OP
       1 天前
    目前退出 debug 放到主动方法调用里测试了,exit 错误不会显示到日志中,代码有错无法看到。
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   1068 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:32 · PVG 02:32 · LAX 10:32 · JFK 13:32
    ♥ Do have faith in what you're doing.