且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

方法必须在Netbeans中调用super()错误

更新时间:2021-07-18 22:51:42

我在另一天才看到这些症状。

I saw these symptoms just the other day.

如果我的文件我一直在编辑,并决定我想把我的更改分成2提交。我去了包含我的文件x / y / Z.java的目录,在x / y名为备份的目录,移动Z.java在那里,并从版本控制拉新的副本。

I had I file I had been editing and decided I wanted to split my changes into 2 commits. I went to the directory containing my file "x/y/Z.java", made a directory in "x/y" named "backup", moved "Z.java" there, and pulled a fresh copy from version control. Note all of this was done outside the IDE.

回到IDE中,我在第一次提交的更改中合并,当我构建I获取Z.java的重复类消息。

Back in the IDE I merged in the changes for the first commit and when I built I got the duplicate class message for "Z.java".

当我将源代码复制到备份时,我在IDE外部做了,它仍然有原始包 xy,我新编辑的Z.java。 NB不会编译新的Z.java,因为它可以看到它已经创建了xyZclass(从x / y / backup / Z.java)。

When I copied the source to "backup" I did it outside the IDE and it still had the original package "x.y" as did my newly edited "Z.java". NB would not compile the new "Z.java" because it could see it had already created "x.y.Z.class" (from "x/y/backup/Z.java").

有2种方法可以解决此问题:

There are 2 ways to fix this:


  1. 将x / y / backup / Z.java重命名为x / y /backup/Z.java.backup。 (防止备份副本被编译。)

  2. 将x / y / backup / Z.java中的包从x.y更改为x.y.backup (使备份创建不同的类文件。)

执行任何更改后,执行清理和构建。 注意:只是构建无法解决问题,您需要执行清除以删除恶意类文件。

After making either of these changes, perform a "clean and build". Note: simply building will not fix the problem, you need to perform a clean to remove the rogue class file.

#1是通过从命令行重命名Z.java完成的,而不是在NB中。 NB不会让您更改文件扩展名。

Note: #1 was done by renaming Z.java from the command line, not within NB. NB will not let you change the file extension.