Java IntelliJ IDEA:断点未命中,显示时没有勾号,只有一个红点

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46692606/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 02:27:01  来源:igfitidea点击:

IntelliJ IDEA: Breakpoint not being hit, and is shown without the tick, just a red dot

javadebuggingintellij-idea

提问by Pablo Matias Gomez

First of all, the most similar question that I found is this Intellij IDEA: Breakpoint not being hit, and is shown greyed outbut that is not the exact same case.

首先,我发现的最相似的问题是这个Intellij IDEA: Breakpoint not be hit,并且显示为灰色,但这不是完全相同的情况。

I have a gradle project, and when I put a breakpoint it is displayed as a red dot, with a tick inside, and it just works fine.

我有一个 gradle 项目,当我放置一个断点时,它显示为一个红点,里面有一个勾号,它工作正常。

working breakpoint

工作断点

The problem is that in some classes (in the same project, not a dependency class), the red dot doesn't have a tick inside, and it doesn't tell why it wouldn't work. And it just doesn't work..:

问题是在某些类中(在同一个项目中,而不是依赖类),红点内部没有勾号,并且它没有说明为什么它不起作用。它只是不起作用..:

enter image description here

在此处输入图片说明

What have I tried so far:

到目前为止我尝试了什么:

  • Gradle clean & build
  • Rebuild project
  • Restart debug
  • Invalidate caches and restart IntelliJ
  • Update IntelliJ to the latest version (2017.2.5)
  • Mute & Unmute breakpoints
  • Gradle 清理和构建
  • 重建项目
  • 重启调试
  • 使缓存无效并重新启动 IntelliJ
  • 更新 IntelliJ 到最新版本 (2017.2.5)
  • 静音和取消静音断点

采纳答案by Kedar Brooks

Did some searching through IntelliJ Help PDF:
Help Docpg. 431

通过 IntelliJ Help PDF:
Help Docpg 进行了一些搜索。431

Their documentation Describes the checkmark as "Shown at run-time when the breakpoint is recognized by the debugger as set on an executable code line."

他们的文档将复选标记描述为“当断点被调试器识别为在可执行代码行上设置时在运行时显示”。

and the regular red dot as "Shown at design-time or during the debugging session when the class with such breakpoint is not yet loaded. "

常规的红点显示“在设计时或调试会话期间,当具有此类断点的类尚未加载时。”

So it would seem that the line you're adding the breaking point to never gets executed. You can try stepping up line by line through the class to make sure the class is not getting hung up somewhere.

因此,您添加断点的行似乎永远不会被执行。您可以尝试在课程中逐行增加,以确保课程不会在某处挂断。

Hope this helps

希望这可以帮助

回答by MattG

I get this same issue intermittently from time to time, I always run the latest version of IDEA. The break points are shown as red but without a tick inside them. Even after I rebuild or re-run in debug they do not get a tick, and they do not "work", i.e., the code continues. I resolve by restarting IDEA, then restarting the debugger/debug run config.

我不时间歇性地遇到同样的问题,我总是运行最新版本的 IDEA。断点显示为红色,但内部没有勾号。即使在我在调试中重建或重新运行后,它们也不会得到滴答声,并且它们不“工作”,即代码继续。我通过重新启动 IDEA,然后重新启动调试器/调试运行配置来解决。

回答by kumar

I had the same issue in my mac, tried restarting server, machine, invalidate caches and nothing helped. Then, I noticed when the server is started in debug mode, i didnt see this message: Connected to the target VM, address: '127.0.0.1:64197', transport: 'socket'and I realized that there could be some problem with the server as such.

我在我的 mac 上遇到了同样的问题,尝试重新启动服务器、机器、使缓存无效,但没有任何帮助。然后,我注意到当服务器在调试模式下启动时,我没有看到这条消息: Connected to the target VM, address: '127.0.0.1:64197', transport: 'socket'我意识到服务器可能存在一些问题。

Solution:Created new server using command line "./server create " and then associated this server for run configuration. Now started server in debug mode and I saw above message connected to socket port and I am able to see the tick marks on debug point.

解决方案:使用命令行“./server create”创建新服务器,然后关联此服务器以进行运行配置。现在在调试模式下启动服务器,我看到上面的消息连接到套接字端口,我能够看到调试点上的刻度线。

回答by KayV

The same happened with me on Mac machine. I followed these steps and all worked fine:

我在 Mac 机器上也发生了同样的情况。我按照以下步骤操作,一切正常:

  1. Stop server.
  2. Close all intellij projects.
  3. Open only the specific intellij project on which my application needs to run.
  4. Start the server in debug mode.
  1. 停止服务器。
  2. 关闭所有 intellij 项目。
  3. 仅打开我的应用程序需要在其上运行的特定 Intellij 项目。
  4. 以调试模式启动服务器。

回答by Abhay Maniyar

I was also facing this issue and found that my tomcat configuration was not right.

我也遇到了这个问题,发现我的tomcat配置不对。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>compile</scope>
</dependency>

The scope tag had value as "provided". Changed it to compile and it worked fine.

范围标签的值为“提供”。将其更改为编译并且运行良好。

回答by Stypox

I fixed this by manually deleting all build-related files (for some reason Rebuild did nothing) by running this command at the project's root folder. Note that it does also remove Intellij's temporary configuration files, that are usually not included in git repositories anyway. Replace MODULE with the subfolder containing the module for the project. If you are building an Android app with Android Studio the main module name is usually app.

我通过在项目的根文件夹中运行此命令手动删除所有与构建相关的文件(出于某种原因 Rebuild 什么都不做)来解决此问题。请注意,它还删除了 Intellij 的临时配置文件,这些文件通常不包含在 git 存储库中。将 MODULE 替换为包含项目模块的子文件夹。如果您使用 Android Studio 构建 Android 应用程序,则主模块名称通常为app.

rm -rf ./local.properties ./.gradle/ ./.idea/ ./MODULE/build/ ./MODULE/out/

Then restart Intellij with the File -> Invalidate Caches / Restartoption, wait for the build and indexing to finish, and debugging should start working again.

然后使用该File -> Invalidate Caches / Restart选项重新启动 Intellij ,等待构建和索引完成,调试应该再次开始工作。

回答by Sizons

I made a n00b mistake on the IDE. Instead of hitting the debug button, I thought it would work the same as visual studio or eclipse in that I'd have to use the run button, yet when I hit the debug button (That looks like an actual bug) my break-point hit just fine.

我在 IDE 上犯了一个 n00b 错误。我没有点击调试按钮,而是认为它与 Visual Studio 或 Eclipse 的工作方式相同,因为我必须使用运行按钮,但是当我点击调试按钮(这看起来像一个实际的错误)时,我的断点打就好了。