Intellij - Errors JAVA (imports, etc...) doesn#39;t detect(Intellij - 错误 JAVA(导入等)未检测到)
问题描述
我开始使用 IntelliJ-IDEA,但我的 java 文件没有检测到例如导入等错误.我没有创建一个项目 java,因为我在同一个项目中使用不同的语言,但我希望在 java 文件中,他检测到错误.我该怎么做?
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 包的来源
- 模块 -> 设置编译类的路径
- Modules -> Libraries - 指定要使用的任何其他 jar.
假设您的项目中有两个 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(导入等)未检测到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Intellij - 错误 JAVA(导入等)未检测到
基础教程推荐
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- 如何对 Java Hashmap 中的值求和 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
