IntelliJ显示构建失败并抛出空指针异常。

huangapple go评论69阅读模式
英文:

IntelliJ says build failed and through Nullpointer Exception

问题

The project在编译时显示零错误,但在构建过程中开始执行时崩溃,并显示以下错误:

Module project_name production java.lang.NullPointerException: 不允许在 THashSet 中使用空元素

但是当我将项目的目录从D盘更改为C盘时,同样的项目开始正常工作。为什么会发生这种情况,我无法解决。请帮忙!

在注释掉这段代码后,它开始工作了,在取消注释的情况下,代码没有变化,它也能正常工作。

// if main db not loaded
if (!Get_db_path.Main_not_found && Db_Connect.conn == null) {
    Sel_db.connect();  // selected database
    Sel_db_error();
}   // display error
Main_db_error(Get_db_path.Main_not_found);

GetToggleStatus();
英文:

The project shows zero errors at compile time but when it starts to execute during build it crashes and says:

IntelliJ显示构建失败并抛出空指针异常。

Module project_name production java.lang.NullPointerException: null elements are not allowed in THashSet

But the same project start working properly when I change its directory from D to C drive. Why this happen I'm unable to solve. Please help!

After comment this code it starts working and after disabling comment with no change in code it also works fine.

// if main db not loaded
if (!Get_db_path.Main_not_found && Db_Connect.conn == null) {
    Sel_db.connect();  // selected database
    Sel_db_error();
}   // display error
Main_db_error(Get_db_path.Main_not_found);

GetToggleStatus();

答案1

得分: 6

这突然发生在我编译运行main方法时。我在IntelliJ中通过重新构建项目来解决了这个问题。

--> 前往Build菜单,然后点击Rebuild Project

下次你运行main方法时,它应该可以正常工作。


<sub>顺便说一句:我在另一个情境中也遇到过这个问题:使用PrintWriter写入ByteArrayOutputStream。</sub>

英文:

This happened suddenly to me at compile time when running the main method.
I solved it in Intellj by just rebuilding the project.

--> Go to the Build menu and click on Rebuild Project.

Next time you run the main method it should just work again.


<sub>Btw: I had this problem in another context: writing to ByteArrayOutputStream with PrintWriter.</sub>

huangapple
  • 本文由 发表于 2020年8月14日 19:34:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/63411990.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定