How to Speed Up IntelliJ IDEA: 10 Essential Fixes for Java Developers
This article lists ten common IntelliJ IDEA pitfalls—such as high memory usage, indexing delays, Lombok errors, broken breakpoints, console encoding issues, unwanted Git commits, slow Maven downloads, classpath mismatches, shortcut conflicts, and automatic code reformatting—and provides step‑by‑step solutions to make the IDE run smoothly for Java and Spring projects.
Introduction
IntelliJ IDEA is a powerful IDE for Java developers, but many users encounter performance and configuration problems that hinder productivity. This guide collects ten classic issues and shows how to resolve them.
IDEA Advantages and Disadvantages
Advantages
Smart code completion surpasses Eclipse.
Robust refactoring (rename, extract method, change signature).
Rich built‑in tools (VCS, database client, HTTP client, terminal).
Extensive plugin ecosystem (Lombok, MyBatis, SonarLint, etc.).
Powerful debugger (conditional breakpoints, expression evaluation, remote debugging, memory analysis).
Disadvantages
High memory consumption (2‑4 GB by default).
Indexing can take minutes for large projects.
Complex configuration; many settings to tune.
Commercial Ultimate edition; some features require a paid license.
10 Common Pitfalls and Solutions
1. IDEA Becomes Laggy and CPU Spikes
Symptoms: After a few hours the IDE freezes for a couple of seconds, mouse cursor spins, and CPU hits 100%.
Root Causes: Insufficient heap memory (default 512 MB‑1 GB) and frequent indexing of large directories such as node_modules.
Solution:
Increase heap size in idea64.exe.vmoptions (or /Applications/IntelliJ IDEA.app/Contents/bin/idea.vmoptions) to at least 2 GB initial and 4 GB maximum, enable G1GC and string deduplication.
# Recommended for an 8 GB machine
-Xms2048m
-Xmx4096m
-XX:ReservedCodeCacheSize=512m
-XX:+UseG1GC
-XX:+UseStringDeduplicationExclude unnecessary folders (e.g., node_modules, .git, target, build) from indexing via File → Settings → Project Structure → Modules → Excluded .
2. Lombok Annotations Show Errors
Symptoms: After updating IDEA or changing configuration, classes annotated with @Data or @Getter are highlighted in red and compilation fails.
Root Causes: Lombok code is generated at compile time; IDEA needs the Lombok plugin and annotation processing enabled.
Solution:
Install and enable the Lombok plugin via File → Settings → Plugins → Marketplace → Lombok .
Enable annotation processing: File → Settings → Build, Execution, Deployment → Compiler → Annotation Processors → Enable annotation processing .
Ensure the Lombok dependency version matches the plugin (e.g., 1.18.30 in pom.xml).
If problems persist, invalidate caches ( File → Invalidate Caches / Restart ) and delete the conflicting .idea configuration files.
3. Debug Breakpoints Do Not Hit
Symptoms: Breakpoints are ignored, sometimes shown with a gray icon, and code runs without stopping.
Root Causes: Breakpoint placed on non‑executable lines, disabled breakpoints, JIT inlining, or conditional breakpoints evaluating to false.
Solution:
Verify breakpoint icons are solid red (no slash). Re‑enable disabled breakpoints via right‑click → Enable.
Place breakpoints on executable statements (e.g., inside method bodies, not on method signatures).
Check for conditional breakpoints with always‑false conditions.
Use Ctrl+Shift+F8 to open the breakpoint management panel.
In complex multithreaded scenarios, print stack traces with Thread.currentThread().getStackTrace() or add logging.
4. Console Shows Garbled Chinese Characters
Symptoms: Output like ??? or 你好 appears instead of Chinese text.
Root Causes: Mismatched encodings among IDEA console, source files, JVM default, and OS.
Solution:
Set all encodings to UTF‑8: File → Settings → Editor → File Encodings → Global, Project, and Properties files to UTF‑8; enable “Transparent native‑to‑ascii conversion”.
Add JVM options -Dfile.encoding=UTF-8 and -Dconsole.encoding=UTF-8 via Help → Edit Custom VM Options .
Configure Maven plugins ( maven‑compiler‑plugin, maven‑surefire‑plugin) to use UTF‑8 encoding.
For Logback or Log4j, set <charset>UTF-8</charset> in the appender configuration.
5. Unwanted .idea Files Commit to Git
Symptoms: Files like .idea/workspace.xml, .iml, or target/ appear in the Commit Changes dialog and get pushed.
Root Causes: IDEA tracks its configuration directory by default; lack of a proper .gitignore.
Solution:
Create a .gitignore at the project root with entries for compiled classes, target/, .idea/, *.iml, logs, and OS files.
In IDEA, go to Settings → Version Control → Ignored Files to ensure the ignore rules are recognized.
If the files were already committed, remove them from the repository cache:
git rm -r --cached .idea
git commit -m "Remove .idea from git"6. Maven Dependency Downloads Are Extremely Slow
Symptoms: Refreshing Maven projects hangs, shows “Transfer failed” or “Read timed out”.
Root Causes: Default Maven Central repository is overseas; no domestic mirror configured; possible lock conflicts in ~/.m2/repository.
Solution:
Add a domestic mirror (e.g., Alibaba Cloud) to a custom settings.xml and point IDEA to it via File → Settings → Build, Execution, Deployment → Build Tools → Maven → User settings file → Override .
<mirrors>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>central</mirrorOf>
<name>Alibaba Cloud Public Repository</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
</mirrors>Disable “Work offline” and enable “Import Maven projects automatically”.
Configure HTTP proxy in Settings → Appearance & Behavior → System Settings → HTTP Proxy if needed.
7. Code Compiles but Fails at Runtime (ClassNotFoundException)
Symptoms: mvn clean compile succeeds, but running the application throws ClassNotFoundException.
Root Causes: IDEA’s output directory differs from Maven’s ( out/ vs target/classes), or Lombok generated code is missing.
Solution:
Enable “Build project automatically” in File → Settings → Build, Execution, Deployment → Compiler .
Set module output paths to target/classes and target/test-classes via File → Project Structure → Modules .
Rebuild the project ( Build → Rebuild Project ) or invalidate caches.
Verify Lombok annotation processing is correctly configured.
8. Shortcut Keys Stop Working
Symptoms: Common shortcuts like Ctrl+C, Ctrl+V, or Ctrl+Alt+L no longer perform their expected actions.
Root Causes: Conflicts with other applications (WeChat, Sogou input method, QQ, etc.) or accidental keymap changes in IDEA.
Solution:
Check the current keymap via File → Settings → Keymap and restore defaults if it was altered.
Identify and disable conflicting shortcuts in external software.
Search for the specific action in the Keymap panel and reassign or remove conflicting bindings.
9. Unable to Connect to MySQL from IDEA Database Tool
Symptoms: Errors like “The server time zone value '???' is unrecognized” or “Could not create connection to database server”.
Root Causes: MySQL 8+ requires the serverTimezone parameter; IDEA’s connection URL lacks it.
Solution:
In the Database tool, open the data source settings, go to the “Advanced” tab, and add serverTimezone=Asia/Shanghai (or UTC).
Alternatively, append the parameter directly to the JDBC URL:
jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf-8Ensure the MySQL driver version matches the server version.
10. Automatic Code Reformatting on Commit Breaks Diffs
Symptoms: Before committing, IDEA reformats code, causing the entire file to appear changed in Git diff.
Root Causes: The “Reformat code” option in the Commit dialog is enabled, and team members use different formatting rules.
Solution:
Option 1 (recommended): Add a project‑wide .editorconfig file to enforce consistent formatting (e.g., 4‑space indent for Java) and share the IDE code‑style settings via version control.
Option 2: Disable automatic reformatting by unchecking “Reformat code”, “Optimize imports”, and “Rearrange code” in File → Settings → Version Control → Commit .
Conclusion
By addressing these ten pitfalls—adjusting memory, managing indexing, configuring Lombok, fixing breakpoints, unifying encodings, cleaning Git commits, speeding up Maven, aligning output paths, resolving shortcut conflicts, handling MySQL time zones, and standardizing code formatting—developers can keep IntelliJ IDEA fast, reliable, and a true productivity booster.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Su San Talks Tech
Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
