intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

在IDEA中右键点击文件夹中的mark directory as 会出现下图所示以设置文件夹种类,那其中文件夹具体有哪些分类呢?

intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

查阅 IntelliJ IDEA 2018.2 Help,内容如下(英语简单,就不用翻译了):

Folder categories

Folders within content roots can be assigned to several categories.

  • Sources Root intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

    Production code that should be compiled.

  • Generated Sources Root intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

    If a folder is marked as generated, the IDE will think that files in this folder are generated automatically rather than written manually, and can be regenerated.

  • Test Sources Root intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

    These folders allow you to keep code related to testing separately from production code. Compilation results for sources and test sources, normally, are placed into different folders.

  • Generated Test Sources Root intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

    If a folder is marked as generated, the IDE will think that files in this folder are generated automatically rather than written manually, and can be regenerated.

  • Resources Root intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复 (available only in Java modules)

    Resource files used in your application (images, configuration XML and properties files, etc.). During the build process, resource files are copied to the output folder as is.

  • Load Path Root intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复 (available only when the Ruby plugin is enabled)

    The load path is the path where the require and load statements look for files.

  • Test Resources Root intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复 (available only in Java modules)

    These folders are for resource files associated with your test sources.

  • Excluded intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

    Files in excluded folders are ignored by code completion, navigation and inspection. That is why, when you exclude a folder that you don't need at the moment, you can increase the IDE performance.

    Normally, compilation output folders are marked as excluded.

    Apart from excluding the entire folders, you can also exclude specific files.

FAQs

开发过程中遇见几个让人很透大的错误(就是关于文件夹种类的!):

1. 包名写对却一直报错问题

intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

这是今天遇到的问题,仔细检查后发现包名根本没写错,可就是报错,然后发现src根本就不是前面所列出的Sources Root ,即里面放置需要编译的代码的文件夹,这个和之前博客中提到的一个文件夹不能创建包和java类的问题是一样的,解决方法就是将文件夹设置成Sources Root就行了!

intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

点击第一个,然后src文件夹就显示蓝色intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

之前的错误也没了!

intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

2. el、jstl表达式突然失效

intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

说起这个问题真的是恨得牙痒痒,曾经因为这个问题放弃了自己的大作业,以为是什么依赖矛盾、编译器问题,甚至还重装了一回intellij。。。

后来发现是main文件夹被排除在外(即mark directory as 设置成了Exclude)了。。。

编译器设置这个是为了提高编译效率,将某些不用的文件夹排除在编译文件夹外,节省编译时间!

main都被排除了,怎么用jar包。。。

所以

intellij中文件夹种类 以及 包名突然报错或者el、jstl等标签突然失效的修复

Cancel Exclusion,错误就没了!哇。。开心中透着一点悲伤,我tmd怎么没早发现。

还有相关问题就接着写,到这了!