intellij中文件夾種類 以及 包名突然報錯或者el、jstl等標籤突然失效的修復

在IDEA中右鍵點擊文件夾中的mark directory as 會出現下圖所示以設置文件夾種類,那其中文件夾具體有哪些分類呢?

查閱 IntelliJ IDEA 2018.2 Help,內容如下(英語簡單,就不用翻譯了):

Folder categories

Folders within content roots can be assigned to several categories.

  • Sources Root Sources root

    Production code that should be compiled.

  • Generated Sources Root icons modules generatedSourceRoot svg

    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 Test Sources Root

    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 Generated Test Sources Root

    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 Resources Root (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 Load Path Root (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 icons modules testResourcesRoot svg (available only in Java modules)

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

  • Excluded Excluded

    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. 包名寫對卻一直報錯問題

這是今天遇到的問題,仔細檢查後發現包名根本沒寫錯,可就是報錯,然後發現src根本就不是前面所列出的Sources Root ,即裏面放置需要編譯的代碼的文件夾,這個和之前博客中提到的一個文件夾不能創建包和java類的問題是一樣的,解決方法就是將文件夾設置成Sources Root就行了!

點擊第一個,然後src文件夾就顯示藍色

之前的錯誤也沒了!

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

說起這個問題真的是恨得牙癢癢,曾經因爲這個問題放棄了自己的大作業,以爲是什麼依賴矛盾、編譯器問題,甚至還重裝了一回intellij。。。

後來發現是main文件夾被排除在外(即mark directory as 設置成了Exclude)了。。。

編譯器設置這個是爲了提高編譯效率,將某些不用的文件夾排除在編譯文件夾外,節省編譯時間!

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

所以

Cancel Exclusion,錯誤就沒了!哇。。開心中透着一點悲傷,我tmd怎麼沒早發現。

還有相關問題就接着寫,到這了!

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章