简体   繁体   English

IntelliJ IDEA - 如何在非 Java 项目中启用 Java 文件的代码完成/调试

[英]IntelliJ IDEA - How to enable code completion / debugging for Java files in non-java project

Often I will have a big repo full of various bits and pieces (some bash, php, config dumps etc).通常我会有一个充满各种点点滴滴的大型仓库(一些 bash、php、配置转储等)。 It is often convenient to be able to open as a single project from the root of the repo.能够从 repo 的根目录作为单个项目打开通常很方便。

However when a Java file is thrown into the mix IntelliJ doesn't seem to accept that it is Java and will not have all the helpful debugging / package import magic.然而,当 Java 文件被放入混合中时,IntelliJ 似乎不接受它是 Java 并且不会有所有有用的调试/ZEFE90A8E604A7C840E88D03A67F6B7D 导入。

How can I force this to be enabled?如何强制启用此功能?

(Taking the java file out, putting it in a Project/src directory and then opening that Project directory as a project will make things work fine - but this is annoying for simple scratch files). (取出 java 文件,将其放在 Project/src 目录中,然后将该 Project 目录作为项目打开,这将使事情正常工作——但这对于简单的临时文件来说很烦人)。

In case it makes any difference I am running:如果它有什么不同,我正在运行:

IntelliJ IDEA 2020.1.1 (Ultimate Edition)
Build #IU-201.7223.91, built on April 30, 2020
Licensed to Ingmar Boddington
Subscription is active until December 2, 2020
Runtime version: 11.0.6+8-b765.40 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.15.4
GC: ParNew, ConcurrentMarkSweep
Memory: 1981M
Cores: 8
Non-Bundled Plugins: io.gulp.intellij, com.jetbrains.php

Configure a new Java module with the source roots set to the folders with your Java files.配置一个新的 Java 模块,将源根设置为包含 Java 文件的文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM