如何避免在Intellij中索引大量文件? [英] How to avoid indexing large amounts of files in Intellij?

查看:88
本文介绍了如何避免在Intellij中索引大量文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Intellij中有一个Java项目,并且有一个数据"目录,其中包含许多JSON文件.我的Intellij必须花很长时间才能对它们进行索引,然后才能从事该项目.我想将此数据目录放在项目中的原因是我可以使用相对路径来访问它们.我正在考虑将此数据/目录移出项目,但是这将阻止我的项目直接访问它们,即我必须在计算机上使用绝对路径来读取文件并将文件写入数据目录.

I have a Java project in Intellij and there is a 'data' directory which hosts lots of JSON files. My Intellij has to takes a very long time to index them before I can work on the project. The reason I want to put this data directory in the project is for me to use relative path to access them. I am thinking to move this data/ directory out of the project, however that will block my project to directly access them, i.e. I have to use absolute path on a machine to read and write files to the data directory.

处理这种情况的正确方法是什么?

What's the right way to handle this situation?

推荐答案

正如注释中所提到的,除非您排除目录,否则intellij似乎并不支持.但是,这样做并不意味着您必须使用绝对路径从程序中读取文件.

As was mentioned in the comments, it doesn't look like intellij supports this unless you exclude the directory. Doing so, however, doesn't mean you have to read the files from your program using an absolute path.

假设我们正在谈论一个从主目录启动的简单程序:

Assuming we are talking about a simple program initiated from the main directory:

  • 在Intellij中,编辑项目"设置,选择模块",选择模块,然后单击源"选项卡
  • 选择数据目录,然后单击标记为:排除"按钮.

现在,在您的应用程序的运行"配置中,将工作目录设置为数据目录(或将其设置为):

Now in the Run configuration for your app, set the working directory to your data directory (or set it to the):

您现在应该可以使用相对路径从代码中访问json文件.在此示例中,路径为." (当前目录),因为Java项目的工作目录是数据目录.

You should now be able to access your json files from within your code using a relative path. In this example, the path would be "." (the current directory) since the working directory for your Java project is the data directory.

这篇关于如何避免在Intellij中索引大量文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆