Confused about how Intellij compiles things and deals with resources

流过昼夜 提交于 2019-12-02 02:45:21
  1. In a Maven project IDE follows Maven rules to process resources so that you will get the consistent results between the command line Maven build and IDEA build. If Maven copies resources to classpath, IDEA will do the same.

  2. From the classpath of the module and its dependencies, normally a .class file is used.

  3. In a non-Maven project resources are copied to the output according to Settings | Compiler | Resource Patterns. In a Maven project resources are handled according to pom.xml resources rules. Files from resources folder are copied automatically. Other folders need to be added to the resources manually using pom.xml.

  4. You can view the classpath in the command line that is printed in the Run console.

  5. In a Maven project use the resources folder. In a non-Maven project the file should be under a source root and its extension needs to be present in the Resource Patterns configuration.

Also note that if you are using a legacy compilation (External Build disabled), IDEA will use Resource Patterns configuration even in Maven projects and the output between IDEA and Maven will be different. The same applies to IDEA 11 and older versions.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!