IntelliJ IDEA 正确设置source directory

来源:互联网 发布:武汉群光mac专柜在哪里 编辑:程序博客网 时间:2024/05/20 01:12

环境

操作系统:win7
IntelliJ IDEA: 2017.3 Ultimate

需求

我上一篇,讲解完,项目的导入。
之后我发现,有些包名报错。弄得的我设置了很久,才设置对了,再次记录下

正确的做法

假设我们类的路径是asd/com/stackoverflow/Test.java这样的;
对于Test.java而言,包名是:com.stackoverflow则,
我们就要把asd设置为Sources

我的配置

这里写图片描述

这里写图片描述

遇到的错误

要是没有设置正确,会出现如下错误:

这里写图片描述

英文如下:

Package name '' does not correspond to the file path '' Detects package statements that do not correspond to the project directory structure and reports classes without package statements

参考地址:

IntelliJ thinks package and file path do not match