javascript 如何在 IntelliJ IDEA 中设置多语言项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14936709/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 22:58:49  来源:igfitidea点击:

How to set up a multi-language project in IntelliJ IDEA

javajavascripthtmlintellij-idea

提问by mr.nothing

Is there a way to open/import an IntelliJ IDEA project which contains different language source files? For example I have Java (Maven) + HTML + JavaScript and, unfortunately, I'm able to import only the Maven project. Is there a way to open/import the entire project as a single whole?

有没有办法打开/导入包含不同语言源文件的 IntelliJ IDEA 项目?例如,我有 Java (Maven) + HTML + JavaScript,不幸的是,我只能导入 Maven 项目。有没有办法将整个项目作为一个整体打开/导入?

Thanks in advance!

提前致谢!

回答by seanmcl

Import the project as a java project. Then in the 'Project Structure' box, click on the module and click the + sign. This allows you to add, e.g., a Python "facet" to the module. I use this frequently to develop mixed Java/Python modules.

将项目导入为 java 项目。然后在“项目结构”框中,单击模块并单击 + 号。这允许您向模块添加,例如,Python“facet”。我经常使用它来开发混合的 Java/Python 模块。

回答by pcalcao

I don't think there is a way of doing that.

我不认为有办法做到这一点。

You'll probably have to import the maven project and then add the rest of the folders, yourself, configure the correct plugins, etc.

您可能必须导入 maven 项目,然后自己添加其余文件夹,配置正确的插件等。

At least that's what I do in a couple of projects where I have Java and Python source files in the mix.

至少这就是我在几个混合了 Java 和 Python 源文件的项目中所做的。

Sometimes, it works even better to simply define different modules for the different types of "sub-project", especially when it's a whole different language and you happen to need to setup a compiler etc, I've ran into some problems with IntelliJ not recognizing my Python modules correctly when I mixed them up in a Java project. All went well when I created a separate module.

有时,为不同类型的“子项目”简单定义不同的模块效果更好,尤其是当它是一种完全不同的语言并且您碰巧需要设置编译器等时,我遇到了一些 IntelliJ 问题,而不是当我在 Java 项目中混合我的 Python 模块时正确识别它们。当我创建一个单独的模块时,一切顺利。