且构网

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

由于“找不到符号类X",因此无法在Intellij Idea中编译Java类.错误

更新时间:2022-03-08 06:24:49

尝试首先编译整个项目(或至少编译类B).

Try compiling the whole project (or at least class B) first.

如果仅编译 A,则无法找到类B,因为该类尚未编译(因此,不存在字节码B.class文件).

If you compile only class A, class B cannot be found because it hasn't been compiled yet (therefore, no bytecode B.class file exists).

这不是直观的,而是真实的.编译单个类时,IDEA不会自动编译依赖类.

This is not intuitive, but true. IDEA doesn't automatically compile dependant classes when you compile single class.