Intellij - 错误JAVA(导入等等)没有检测到 [英] Intellij - Errors JAVA (imports, etc...) doesn't detect
问题描述
我开始使用 IntelliJ-IDEA
,但我的 java
文件未检测到导入等错误例如。我没有创建一个项目 java
,因为我在同一个项目中使用不同的语言,但我希望在 java $ c中$ c>文件,他检测错误。我怎样才能做到这一点?
I'm starting use the IntelliJ-IDEA
, but my java
files doesn't detect errors like imports for example. I don't create one project java
, because i'm using different languages in same project, but I want that in the java
files, he detect the errors. How can I make this?
推荐答案
Intellij可以很好地完成标准项目布局。如果你的标准不合适 - 请告诉Intellij结构如何:从打开的工作区,选择文件 - >项目结构(Ctrl + Alt + Shift + S),然后浏览所有选项卡以设置细节:
Intellij can work very well standard project layouts. If yours is not standard - tell Intellij how it is structured: from open workspace, select File -> Project Structure (Ctrl+Alt+Shift+S), and go through all the tabs to setup specifics:
最重要的标签可能是:
- 项目标签,您可以在其中指定要与项目一起使用的jdk( JAVA_HOME如果你愿意的话)
- 模块 - >你告诉intellij哪些目录应被视为java包的来源
- 模块 - >设置路径你想要编译已编译的类
- 模块 - >库 - 指定要使用的任何其他jar。
- Project tab, where you specify jdk to use with the project (JAVA_HOME if you will)
- Modules -> Sources where you tell intellij which directories should be treated as java packages
- Modules -> Paths to setup where you want to put compiled classes
- Modules -> Libraries - to specify any additional jars to be used.
假设您的项目中有两个java文件:
Assume you have two java files in your project:
package com.myproject // this one have package
public class SomeClass{
//whatever
}
和
public class Main {
// whatever - no package
}
所以你应该将它们放在某个目录中:
so you should have them inside some directory:
directory
|- com
| |- mypackage
| |- SomeClass.java
|- Main.java
在这种结构中 - 目录
是源根目录。将其标记为
In such structure - the directory
is sources root. Mark it as such
这篇关于Intellij - 错误JAVA(导入等等)没有检测到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!