[IDE] Intellij IDEA FAQ
IDEA FAQ
Q: [工具/IDE]IDEA 常用插件
Q: [JDK] Intellij IDEA中设置JDK版本
Q:IDEA Java 项目的.idea文件夹及.iml文件的作用
IDEA是一个广泛使用的集成开发环境,它提供了许多有用的工具和功能来帮助开发人员更有效地编写代码。
.idea文件夹
- 在IDEA中,每个项目都会有一个与之关联的
.idea文件夹,其中包含了与项目相关的各种配置文件和元数据。
下面详细介绍
.idea文件夹下各个文件的作用:
workspace.xml
- workspace.xml:这个文件保存了项目的工作区配置,包括打开的文件、窗口布局、工具窗口的状态、Maven配置、
Git仓库配置及代码变更文件等。
.idea/workspace.xml是JetBrains系列IDE(集成开发环境)中的一个配置文件,用于存储项目的工作空间配置信息。
它是一个XML格式的文件,包含了项目的各种设置和状态。
它类似于一个个人工作空间的设置,这些设置会在你每次打开IDEA时被加载。
workspace.xml文件通常包含以下内容:
- 项目的基本信息:包括项目名称、根目录、文件编码等。
- 项目的模块和依赖:记录了项目的模块结构和依赖关系。
- 编辑器设置:包括代码风格、缩进、自动补全等编辑器相关的配置。
- 版本控制设置:记录了项目使用的版本控制系统(如Git、SVN)的配置信息。
- 运行和调试配置:包括项目的运行和调试配置,如启动参数、环境变量等。
- 插件和工具配置:记录了项目使用的插件和工具的配置信息。
- 重新生成 workspace.xml 的方法:重新运行一下idea的maven或其他功能均可触发IDEA二次生成本文件。
- 注意,二次生成后的
workspace.xml的文件,需要重新配置下 Maven 等配置项(因:此时已恢复为IDEA默认设置)
- 样例文件
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="cf51dab5-dd4d-4283-b9b1-520132168a1a" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/xxx-yyy-service-common/src/test/java/com/xxx/yyy/zzzservice/common/connector/kafka/Constants.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/xxx-yyy-service-common/src/test/java/com/xxx/yyy/zzzservice/common/connector/kafka/UncompressCompressedParsedMessageTest.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xxx-yyy-service-common/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/xxx-yyy-service-common/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="mavenHome" value="D:/Program/maven/apache-maven-3.8.1" />
</MavenGeneralSettings>
</option>
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"git-widget-placeholder": "develop-xxx",
"settings.editor.selected.configurable": "preferences.pluginManager"
}
}]]></component>
<component name="RunAnythingCache">
<option name="myCommands">
<command value="mvn idea:module" />
</option>
</component>
<component name="TaskManager">
<servers />
</component>
</project>
modules.xml
- modules.xml:这个文件记录了项目中的模块信息,包括每个模块的依赖关系、源代码路径、输出路径等。它帮助IDEA理解项目的结构,以便更好地管理代码和资源。
compiler.xml
- compiler.xml:这个配置文件主要保存编译相关的信息,包括项目包含的模块名称、源码编译后
.class文件输出的目录、测试文件编译后输出路径,以及编译时使用的jdk版本等。
encodings.xml
- encodings.xml:这个文件用于指定某个目录下文件的默认编码。在多语言环境下开发时,正确的编码设置至关重要,否则可能会导致乱码等问题。
jarRepositories.xml
- jarRepositories.xml:该文件包含了maven里面定义的jar包数据源的信息,包括存库的id、名称和url。这对于需要使用第三方库或依赖的项目来说非常有用。
其他插件配置
- 其他插件配置:IDEA支持各种插件,这些插件可能会在
.idea文件夹下生成自己的配置文件。这些配置文件通常用于存储与特定插件相关的设置和配置信息。
小结
-
这些文件共同协作,使得IDEA能够为开发人员提供一个高效、个性化的开发环境。
-
了解这些文件的用途和功能,可以帮助你更好地管理项目和配置IDEA,从而提高你的开发效率。
-
请注意,随着IDEA版本的更新,这些文件的格式和内容可能会发生变化。
因此,如果你在使用过程中遇到任何问题,建议查阅IDEA的官方文档或寻求社区的帮助。
同时,对于重要的项目,定期备份.idea文件夹也是一个好习惯,以防意外情况发生导致数据丢失。
总的来说,.idea文件夹下的各个文件为IDEA提供了丰富的项目信息和配置选项。
通过合理地利用这些设置和配置,开发人员可以更好地组织和管理自己的代码,从而更高效地进行开发工作。
.iml文件
-
重新生成
.iml文件的指令 :mvn idea:module -
样例文件:
xxx-kkk-service-parent.iml
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="SonarLintModuleSettings">
<option name="uniqueId" value="9f01efe4-6949-4a38-b9cf-8ef42b49b421"/>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/target/classes"/>
<output-test url="file://$MODULE_DIR$/target/test-classes"/>
<content>
<excludeFolder url="file://$MODULE_DIR$/target"/>
</content>
</component>
</module>
- 样例文件:
xxx-yyy-service-parent.iml
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<module version="4" relativePaths="false" type="JAVA_MODULE">
<component name="NewModuleRootManager">
<exclude-output/>
<orderEntry type="inheritedJdk"/>
<!-- output url="file://$$MODULE_DIR$$/${maven.build.dest}"/ -->
<!-- output-test url="file://$$MODULE_DIR$$/${maven.test.dest}"/ -->
<content url="file://$MODULE_DIR$">
<!-- sourceFolder url="file://$$MODULE_DIR$$/${pom.build.sourceDirectory}" isTestSource="false"/ -->
<!-- sourceFolder url="file://$$MODULE_DIR$$/${pom.build.testSourceDirectory}" isTestSource="true"/ -->
<excludeFolder url="file://$MODULE_DIR$/target"/>
</content>
<orderEntry type="sourceFolder" forTests="false"/>
<!-- Next include each dependency:
<orderEntry type="module" module-name="${dep.artifactId}"/>
<orderEntry type="module-library">
<library name="${dep.artifactId}">
<CLASSES>
<root url="jar://${lib.path}!/"/>
</CLASSES>
<JAVADOC/>
<SOURCES/>
</library>
</orderEntry>
-->
<output url="file://$MODULE_DIR$/target/classes"/>
<output-test url="file://$MODULE_DIR$/target/test-classes"/>
</component>
<component name="ModuleRootManager"/>
<!-- If it's a war project:
<component name="WebModuleProperties">
<containerElement type="module" name="${dep.artifactId}">
<attribute name="method" value="1" />
<attribute name="URI" value="/WEB-INF/classes" />
</containerElement>
<containerElement type="library" level="module" name="${dep.artifactId}">
<attribute name="method" value="1" />
<attribute name="URI" value="/WEB-INF/lib/${dep.systemPath.name}" />
</containerElement>
<deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/${pom.build.warSourceDirectory}/WEB-INF/web.xml" version="" />
<webroots>
<root url="file://$MODULE_DIR$/${pom.build.warSourceDirectory}" relative="/" />
</webroots>
</component>
-->
</module>
Q:IDEA打不开时,如何调试、查看IDEA自身的启动日志?
- 编辑安装目录下的
idea.bat,在配置文件底部添加pause指令
D:\Program\IDEA\IDEA_COMMUNITY_2023.2\bin\idea.bat
注,不是在此目录:
%HOMEPATH%\AppData\Roaming\JetBrains\IdeaIC2023.2\
eg: \Users\xxx\AppData\Roaming\JetBrains\
%USERPROFILE%\AppData\Roaming\JetBrains\IdeaIC2023.2\
eg: C:\Users\xxx\AppData\Roaming\JetBrains\IdeaIC2023.2\
如果没有添加,请在
idea.bat文件末尾添加pause命令,保存后关闭文件。
- 查看错误日志
双击运行IDEA的启动文件(
idea64.exe),此时应该会显示一个错误信息。请务必仔细阅读错误信息,并根据错误信息进行下一步排查。
- 检查IDEA配置文件
在IDEA的安装路径下找到配置文件夹(一般为config),在该文件夹下找到idea.properties文件,使用记事本打开该文件。检查文件中是否存在语法错误或者配置项不正确的情况,如果有,请根据需要进行修改。
D:\Program\IDEA\IDEA_COMMUNITY_2023.2\bin\idea.properties
- 参考文献
Q:IDEA 打开项目或调试、构建项目时,workspace.xml 异常,乃至报:"nameId is invalid: fileId=973410, parentId=0, nameId=0"错误
- 问题描述
IDEA 能正常运行,打开其他项目或调试/构建其他项目时正常,但打开问题项目或调试、构建问题项目时,
workspace.xml异常,乃至报:"nameId is invalid: fileId=973410, parentId=0, nameId=0"错误
- 原因分析:
nameId is invalid: fileId=973410, parentId=0, nameId=0
- IntelliJ IDEA 在加载虚拟文件系统(Virtual File System)时遇到了异常,可能是由于文件系统某些信息损坏或错误导致的。
- 解决方法1:清理 IntelliJ IDEA 缓存
亲测,无效
> + 关闭 IntelliJ IDEA。
- 找到 IntelliJ IDEA 的缓存文件夹,通常位于以下路径之一:
C:\Users\YourUsername\.IntelliJIdea\system\
C:\Users\YourUsername\.IdeaIC\system\
- 删除该文件夹中的 caches 文件夹。
- 重新启动 IntelliJ IDEA。
- 解决方法2:修复文件系统或问题文件
亲测,无实际可行的操作方法
- 解决方法3:删除并重新配置
.idea\workspace.xml文件来解决
亲测,有效(重新生成
workspace.xml后,需重新配置Maven)
- 把
.idea\workspace.xml备份或移除- 重新运行IDEA的
Maven或其他任意功能,会生成一份新的workspace.xml。- 通过配置IDEA的Maven等配置,或直接编辑
workspace.xml,以修正新的workspace.xml
- 参考文献
Q: 启动IDEA中的Spring应用程序时,报"Error:java: 读取D:\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr3Error:java: 读取jar出错"
问题描述
IDEA错误
Error:java: 读取D:\install\maven\maven-repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.10.2\jackson-datatype-jsr310-2.10.2.jar时出错; error in opening zip file
- 错误原因:
- 原因1: 文件内容错误(①pom.xml、jar 里面是 503 的 html 错误码网页;②文件损坏)。
可以重新删除对应的报错文件,手动下载正确的文件;或者 maven 重新引入
解决方法
- 方法1
删除仓库下报错的文件夹(
一定要删除文件夹,只删除jar包没用)
删除之后重新import、或者手动下载对应文件,即可解决报错
- 方法2
如果项目中编译错误的类文件比较少,可以在错误的类上,如图所示,右击选择
Exclude from Compile,将这个编译错误的类排除编译,就可以继续运行Test的main方法了。
但如果项目中编译错误的类比较多,排除方法比较麻烦,不建议这么操作
参考文献
- Error:java: 读取D:\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr3Error:java: 读取jar出错 - CSDN
- 有其它类编译错误idea如何单独运行main方法 - 百度经验
Q: 只执行当前java文件,忽略其他java文件的编译错误
本来我们全部的java文件都是对的,但是突然改变了其中的一个代码文件,造成其他相关的Java文件跟着一块错:4 related problems,当运行时会导致其他文件报错,而不能执行此代码。

解决方法 [转载]
- Step1 点击
Run

- Step2 点击
Edit Configurations

- Step3 点击左下角的
Edit Configurations templates

- Step4 先点击
Application,然后再点击Modify options

- Step5 点击
Add before launch task

然后,这里就多了这个设置

- Step6 点击
Add task再点击Build no erorr check

最后的页面变成了这样子:

Before launch: = 在启动程序前
Build no error check = 不错误检查
参考文献
Q: IDEA编译错误PersistentEnumerator storage corrupted
问题描述
错误信息格式:
org.jetbrains.jps.builders.storage.BuildDataCorruptedException: com.intellij.util.io.PersistentEnumeratorBase$CorruptedException: PersistentEnumerator storage corrupted C:Usersycy.IntelliJIdea2017.2systemcompile-serveride_81e5539ackward-refs
解决思路
一般情况下,在这个异常之后都会跟着问题文件的具体位置,如C:Usersycy.IntelliJIdea2017.2systemcompile-serveride_81e5539ackward-refs,找到对应文件或文件夹,删除该文件或文件夹,重启idea即可
如:
C:\Users\{user}\AppData\Local\JetBrains\IdeaIC2022.2\compile-server\xxx_service_ae75f368\targets
参考文献
- IDEA编译错误PersistentEnumerator storage corrupted - CSDN
- intellij启动报错:com.intellij.util.io.PersistentEnumeratorBase$CorruptedException - CSDN
Q: IDEA断点失效,报:Skipped breakpoint at xxxx because of stepping in another thread Troubleshooting guide
问题描述
IDEA断点FlinkJob程序时,报如下错误:
Skipped breakpoint at com.xxx.core.SignalFieldMappingBroadcastProcessFunction:51 because of stepping in another thread Troubleshooting guide),且按官网的提示Troubleshooting guide
问题分析&解决方法
- Step1 确认没有关闭
View BreakPoints的断点、和启用【禁用断点】(Mute Break Points)


- Step2 确认按照提示的Troubleshooting guide做法,依旧无效


- Step3 都不行时,有可能的工程下(
.idea子目录)中有某些特殊的配置导致的。
操作方法:备份变更内容,重新从【GIT远程仓库】下载源码,再使用IDEA
补充说明:尤其是你在别的工程、或者别人的电脑上可以断点,而你不行时

参考文献
- skipped.breakpoints - Jetbrains
- https://www.jetbrains.com/help/idea/using-breakpoints.html
- https://www.jetbrains.com/help/idea/stepping-through-the-program.html
- https://www.jetbrains.com/help/idea/2023.1/stepping-through-the-program.html#step-into
- https://intellij-support.jetbrains.com/hc/en-us/community/posts/206168219-Impossible-to-control-which-thread-is-stepped-in-debugger-Debugger-rapidly-oscillates-between-threads-
- #IDEA-73165# Multiple threads debugging at the same time not very usable - jetbrains/IDEA
- #IDEA-43728# Provide a way to step in a chosen thread while others remain suspended - jetbrains/IDEA
提供一种在其他线程保持挂起状态时进入所选线程的方法
- https://www.jetbrains.com.cn/idea/download/other.html
- https://www.jetbrains.com/idea/download/?section=windows
Q: IDEA运行失败,报"Command line is too long. Shorten the command line via JAR manifest or via a classpath file and rerun."
- 问题分析
表明命令行太长,可能是因为项目的依赖项过多,导致启动命令行的长度超出了系统的限制。
- 解决方法
Edit Configuration-Modify Options

Shorten command line

- 选择
JAR manifest
- 保存,即可
Q: IDEA根据修改的源码,实时刷新编译结果目录target
问题描述
- 修改源代码后,target目录的代码仍是老代码。
解决方法
IDEA-Settings-Build,Execution,Deployment-Compiler
- [√]
Automatically show first error in editor- [√]
Display notification on build completion- [√]
Build project automatically【最重要的配置项,其他配置项非本问题的相关配置(但推荐)】- [√]
Compile inpendent modules in parallel

参考文献
- 【工具篇】开始开发前,配置好你的idea - CSDN 【推荐】
- 解决 IntelliJ IDEA 中代码无法及时更新的问题 - 腾讯云 【推荐】
- idea中target中的.class源代码文件 不及时更新 需要手动启服务 才刷新 - CSDN 【推荐】
Q: 解决 IntelliJ IDEA 中Java代码无法及时更新、每次都需手动重新编译(mvn clean install)而无法自动编译更新的问题
问题描述
- IntelliJ IDEA 中代码无法及时更新、每次都需手动重新编译(
mvn clean install)而无法自动编译更新
例如,我修改了
App.java代码后,直接Run或Debug,代码并未按照最新修改后的代码运行,需要人工mvn clean install。
- 在 A 工程中不存在此现象,在 B 工程中存在此现象。
解决方法:使用 Maven 的持续构建功能(人工编译法,略过)
本方法,本质上还是人工编译,不可取。
Maven 提供了一个持续构建的功能(
mvn compile),可以在代码修改后自动重新编译。
配置步骤:
-
打开终端:
- 在 IDEA 中,打开底部的
Terminal标签。
- 在 IDEA 中,打开底部的
-
启动 Maven 持续构建:
- 在终端中运行以下命令:
mvn compile - 如果需要持续监控文件变化并自动编译,可以使用
mvn compile的-Dwatch选项(如果支持)。
- 在终端中运行以下命令:
mvn compile -Dwatch
- 测试自动编译:
- 修改 Java 代码后,Maven 会自动检测文件变化并重新编译。
解决方法:启用 IDEA 的自动编译功能
IDEA 提供了自动编译功能,可以在代码修改后自动触发编译。
配置步骤:
-
打开设置:
- 进入
File->Settings(Windows/Linux)或IntelliJ IDEA->Preferences(macOS)。
- 进入
-
启用自动编译:
- 在设置中,导航到
Build, Execution, Deployment->Compiler。 - 勾选
Build project automatically(自动构建项目)。 - 勾选
Compile independent modules in parallel(并行独立编译模块,加快编译速度)
- 在设置中,导航到
-
启用【运行时编译】:
- 在设置中,导航到
Advanced Settings。 - 勾选
Allow auto-make to start even if developed application is currently running(允许在应用程序运行时自动编译,默认是未勾选的)。
- 在设置中,导航到
-
应用设置:
- 点击
Apply和OK保存设置。
- 点击
-
测试自动编译:
- 修改 Java 代码后,IDEA 会自动触发编译,无需手动执行
mvn clean install。
- 修改 Java 代码后,IDEA 会自动触发编译,无需手动执行
解决方法:清除 IDEA 目标工程的缓存 (亲测无效果,但可尝试)
-
清除缓存:
IntelliJ IDEA会缓存编译的文件和类,如果缓存出现问题,可能会导致代码无法及时更新。 -
您可以尝试清除缓存来解决这个问题:
- 在菜单栏中选择
File -> Invalidate Caches / Restart...,然后选择Invalidate and Restart。- 这将清除缓存并重新启动 IntelliJ IDEA。
解决方法:为 Run/Debug Configration 配置Before launch的执行命令
Run/Debug Configration-Modify Options-Before launch-Run Maven Goal/或其他需要的策略



解决方法:删除、重命名或移除 IDEA 目标工程目录下.idea 文件夹 和所有的 .iml文件,并退出IDEA、以File-Open方式重新打开目标工程 (亲测有效、终极大法、推荐)
- 操作步骤:
- 删除、重命名或移除 IDEA 目标工程目录下
.idea文件夹 和所有的.iml文件- 退出IDEA
- 以
File-Open方式重新打开目标工程
- 方法缺点:目标工程下原来的IDEA设置,重新导入后,需要重新配置。
- maven : maven 版本及 settings 配置需要重新配
- jdk : jdk 版本需要重新配置
- 其他未知的配置项的配置 ...
解决方法:使用 JRebel 实现热部署 (未亲测)
JRebel 是一款热部署工具,可以在代码修改后自动重新加载类,而无需重启应用或手动执行
mvn clean install。
配置步骤:
-
安装 JRebel 插件:
- 在 IDEA 中,进入
File->Settings->Plugins。 - 搜索
JRebel并安装。
- 在 IDEA 中,进入
-
激活 JRebel:
- 安装完成后,按照提示激活 JRebel(需要注册账号并获取许可证)。
-
启用 JRebel:
- 在 IDEA 中,右键点击项目,选择
JRebel->Add JRebel Nature。 - 在运行配置中,选择
Run with JRebel。
- 在 IDEA 中,右键点击项目,选择
-
测试热部署:
- 修改 Java 代码后,JRebel 会自动重新加载类,无需重启应用。
解决方法:结合 Spring Boot DevTools 实现热部署 (未亲测)
如果你的项目是 Spring Boot 应用,可以使用
Spring Boot DevTools实现热部署。
配置步骤:
-
添加依赖:
- 在
pom.xml中添加以下依赖:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency>
- 在
-
启用自动重启:
Spring Boot DevTools默认会监控src/main/resources和src/main/java目录下的文件变化,并在修改后自动重启应用。
-
测试热部署:
- 修改 Java 代码后,Spring Boot 会自动重启应用。
解决方法:配置 Maven 编译插件实现自动编译 (未亲测)
可以通过配置 Maven 插件(如
maven-compiler-plugin)实现自动编译。
配置步骤:
- 在
pom.xml中配置插件:- 添加以下配置:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
-
启用 Maven 自动构建:
- 在 IDEA 中,进入
File->Settings->Build, Execution, Deployment->Build Tools->Maven->Runner。 - 勾选
Delegate IDE build/run actions to Maven(将 IDE 的构建/运行操作委托给 Maven)。
- 在 IDEA 中,进入
-
测试自动编译:
- 修改 Java 代码后,Maven 会自动触发编译。
其他方法 (仅供参考,未亲测)
-
检查文件修改时间:如果您的代码文件被其他程序修改过,可能会导致
IntelliJ IDEA无法识别到文件的变化。您可以尝试关闭其他程序,然后重新打开 IntelliJ IDEA。 -
检查代码冲突:如果您正在使用版本控制系统(如 Git),并且代码存在冲突,可能会导致代码无法及时更新。在这种情况下,您需要解决冲突并重新提交代码。
-
重启
IntelliJ IDEA:有时简单地重启 IntelliJ IDEA 可以解决一些问题。您可以尝试关闭 IntelliJ IDEA,然后重新打开它。 -
检查网络连接:如果您正在使用远程仓库或需要下载依赖项,网络问题可能会阻止代码更新。请确保您的网络连接正常,并且可以访问远程仓库或下载依赖项。
-
检查磁盘空间:如果您的磁盘空间不足,可能会导致 IntelliJ IDEA 无法正常工作。请确保您的磁盘有足够的空间来存储项目文件和缓存。
-
升级 IntelliJ IDEA:如果您使用的是较旧的 IntelliJ IDEA 版本,升级到最新版本可能会解决您的问题。新版本通常修复了旧版本中的一些问题,并提供了更好的性能和稳定性。
-
检查系统日志:系统日志中可能包含有关 IntelliJ IDEA 问题的更多信息。您可以在操作系统中查找相关日志文件,并检查是否有任何与 IntelliJ IDEA 相关的问题或错误。
参考文献
- IDEA如何设置自动编译 - 百度经验
- 解决 IntelliJ IDEA 中代码无法及时更新的问题 - 腾讯云 【推荐】
- IDEA 如果 调试的时候,workspace.xml 异常 - 博客园 (亲测无效)
把workspace.xml 删除,重新运行,会生成一份新的workspace.xml
- 启用运行时编译:
Settings-Advanced Setting-Compiler-Allow auto-make to start even if developed application is currently running
- 问题描述:修改代码,idea需要mvn clean install,比较麻烦费时问题
- 删除.idea, 删除后重新导入
- 通过配置Before launch, 添加Run Maven Goal 命令来实现
- 检查没有生效的根本原因
- xxx.class文件是否编译,可以通过文件修改时间确定,or 反编译后检查(拖到idea中即可)
- 针对上一步的情况做具体的分析
Q: 每次在IDEA运行时,都需要被重新编译,影响开发效率,如何优化?
- 解决方法
- 方法1: 删除工程内的
.iml/.ipr/.idea/等 IDEA的 文件;然后,重启IDEA,并重新导入该工程 (20250326 亲测有效)- 方法2:修改运行配置
打开运行/调试配置(Run/Debug Configurations)。
选择你的运行配置。
在“Before launch”部分,移除或调整构建步骤(Build)。
- 方法3: 检查自动编译设置
File -> Settings -> Build, Execution, Deployment -> Compiler
取消勾选“
Build project automatically”。
- 方法4: 使用增量编译
确保开启了增量编译功能,虽然这不会完全取消编译,但可以加快编译速度。
在相同的Compiler设置页面,确保“Compile independent modules in parallel”和“Use precompiled files for composite build”被选中。
- 方法5: 考虑使用 Make 模块
在某些情况下,仅对修改过的文件进行编译(Make)可能比全量编译更高效。
Q:IDEA 构建速度慢的问题,如何优化、提速?
- 参考文献
- 背景
由于项目扩展,项目模块越来越多也越来越大。
每次项目启动,构建时间非常长,严重影响做牛马的效率。
也在网上找寻提升构建速度的方法,但都不适用,自己研究了下,找到了提升效率的方法,用起来比较舒服,决定来分享分享。
- 前置要求
本方案适用于使用 IDEA 和 Maven 进行开发的项目
我当前使用的版本是 IDEA 2023.2 和 Maven 3.8.6,但此方法在其他较新版本中也依然适用。
- IDEA 构建慢的原因
IDEA 在启动项目时使用的是其内置的 Maven,而这个内置的 Maven 是单线程执行构建任务的。
当项目变得庞大且模块繁多时,逐个构建模块的效率自然很低。
此外,IDEA 内置的 Maven 构建配置较为局限,无法根据项目需求进行有效的调优,这也是构建速度慢的原因之一。
- 设置步骤
- 开启多线程
打开 IDEA 设置:文件 > 设置 > 构建、执行、部署 > 构建工具 > Maven - 找到“线程计数(Thread Count)”,设置为多线程模式(可根据个人电脑的配置设置线程数量,我设置的是 10 个线程)。

- 将IDEA的构建/运行委托给MVAEN
IDEA 默认使用其内置的构建工具执行构建,可以将其委托给 Maven,以获得更好的性能:- 打开 IDEA 设置:文件 > 设置 > 构建、执行、部署 > 构建工具 > Maven - 勾选“将 IDE 构建/运行委托给 Maven”


- 添加配置文件
要进一步优化构建,可以通过添加
Maven扩展和缓存配置来提高构建效率。
- 步骤
(1) 在项目根目录下创建.mvn文件夹。
(2) 在.mvn文件夹下添加extensions.xml文件,内容如下
<extensions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/EXTENSIONS/1.0.0"
xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>org.apache.maven.extensions</groupId>
<artifactId>maven-build-cache-extension</artifactId>
<version>1.1.0</version>
</extension>
</extensions>
(3) 在
.mvn文件夹下添加maven-build-cache-config.xml文件,内容如下
<?xml version="1.0" encoding="UTF-8" ?>
<!---
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0"
xsi:schemaLocation="http://maven.apache.org/BUILD-CACHE-CONFIG/1.0.0 https://maven.apache.org/xsd/build-cache-config-1.0.0.xsd">
<!--
Template Maven build cache configuration
-->
<configuration>
<enabled>true</enabled>
<hashAlgorithm>SHA-256</hashAlgorithm>
<validateXml>true</validateXml>
<remote enabled="false">
<url>http://host:port</url>
</remote>
<local>
<location>.build-cache</location>
<maxBuildsCached>3</maxBuildsCached>
</local>
<projectVersioning adjustMetaInf="true"/>
</configuration>
<input>
<global>
<glob>
{*.java,*.groovy,*.yaml,*.svcd,*.proto,*assembly.xml,assembly*.xml,*logback.xml,*.vm,*.ini,*.jks,*.properties,*.sh,*.bat}
</glob>
<includes>
<include>src/</include>
</includes>
<excludes>
<exclude>pom.xml</exclude>
</excludes>
</global>
<plugins>
<plugin artifactId="codegen">
<effectivePom>
<excludeProperties>
<excludeProperty>111</excludeProperty>
</excludeProperties>
</effectivePom>
<dirScan mode="auto">
<excludes>
<exclude tagName="outputDirectory"/>
<exclude tagName="directory"/>
</excludes>
<tagScanConfigs>
<tagScanConfig tagName="someProperty" glob="*.java" recursive="false"/>
</tagScanConfigs>
</dirScan>
<executions>
<execution>
<execIds>
<execId>1</execId>
<execId>2</execId>
</execIds>
<dirScan mode="auto">
<includes>
<include tagName="protolocation" recursive="false" glob="*.proto"/>
</includes>
</dirScan>
</execution>
</executions>
</plugin>
</plugins>
</input>
<executionControl>
<runAlways>
<plugins>
<plugin artifactId="maven-failsafe-plugin"/>
<plugin artifactId="flatten-maven-plugin"/>
</plugins>
<executions>
<execution artifactId="maven-deploy-plugin">
<execIds>
<execId>my-execution-id</execId>
</execIds>
</execution>
</executions>
<goalsLists>
<goalsList artifactId="maven-install-plugin">
<goals>
<goal>install</goal>
</goals>
</goalsList>
<goalsList artifactId="maven-deploy-plugin">
<goals>
<goal>deploy</goal>
</goals>
</goalsList>
<goalsList artifactId="bb-sdk-codegen">
<goals>
<goal>deploy-local</goal>
</goals>
</goalsList>
</goalsLists>
</runAlways>
<reconcile logAllProperties="true">
<plugins>
<plugin artifactId="maven-compiler-plugin" goal="compile">
<reconciles>
<reconcile propertyName="source"/>
<reconcile propertyName="target"/>
<reconcile propertyName="debug"/>
<reconcile propertyName="debuglevel"/>
</reconciles>
<!-- whitelist of logged properties-->
<logs>
<log propertyName="includes"/>
<log propertyName="excludes"/>
<log propertyName="argLine"/>
</logs>
</plugin>
<plugin artifactId="duplicate-finder-maven-plugin" goal="check">
<reconciles>
<reconcile propertyName="skip" skipValue="true"/>
<reconcile propertyName="quiet" skipValue="true"/>
</reconciles>
</plugin>
<plugin artifactId="maven-enforcer-plugin" goal="enforce">
<reconciles>
<reconcile propertyName="skip" skipValue="true"/>
</reconciles>
<!-- blacklisted from logging properties-->
<nologs>
<nolog propertyName="redundantProperty"/>
<nolog propertyName="redundantProperty2"/>
</nologs>
</plugin>
</plugins>
</reconcile>
</executionControl>
</cache>
Q: IDEA build artifacts 过程很慢的解决方案?
Q: Intellij IDEA解决java.lang.VerifyError: Expecting a stackmap frame at branch target的方法
Q: [IDE] IntelliJ IDEA 不能识别 Java 项目
Q:IDEA运行Java类时报错:Error running 'MainTest': Command line is too long. Shorten command line for MainTest or also for Application default configuration
Q: IDEA中javac编译时错误,报:源发行版与目标发行版的字节码版本不一致
IDEA 配置优化篇
Q:优化导包配置

Q:自定义创建live template,快速写代码

只要输入apr ,就能自动提示,并且生成Autowired 语句了。可以根据自己的代码习惯,自定义一些代码模板,帮助我们快速写代码。

Q:取消tab页单行显示


多行显示更多的文件,方便查看。
Q:优化版本控制的目录颜色展示

Q:创建文件时,自动生成作者和时间信息

X 参考文献
本文链接: https://www.cnblogs.com/johnnyzen
关于博文:评论和私信会在第一时间回复,或直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
日常交流:大数据与软件开发-QQ交流群: 774386015 【入群二维码】参见左下角。您的支持、鼓励是博主技术写作的重要动力!


浙公网安备 33010602011771号