選中java 文件所在的package右鍵選中Mark Directory as---Sources Root
若此時運行時彈出:
cannot start compilation:the output path is not specified for module specify the output path in the project structure dialog
出現該錯誤是在intelliJ IDEA 中創建項目之後沒有指定項目編譯輸出的地方,指定位置即可。如下圖: