Fundamentals 24 min read

Turn a Laggy IntelliJ IDEA into a Fast IDE with Simple Tweaks

This article lists ten common IntelliJ IDEA pitfalls—from high CPU usage and Lombok errors to Maven download slowness and Git commit issues—and provides step‑by‑step configurations, memory tweaks, plugin settings, and .gitignore rules to make the IDE run smoothly for Java developers.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Turn a Laggy IntelliJ IDEA into a Fast IDE with Simple Tweaks

Introduction

IntelliJ IDEA is a daily tool for every Java developer, but many of us have encountered problems such as sudden freezes, compilation failures, or debugging issues. This guide collects the ten most classic pitfalls and shows how to solve them.

Pitfall 1: IDEA becomes increasingly laggy, CPU spikes

Symptoms

After a few hours of use, typing feels delayed, the mouse spins, and CPU often hits 100%.

Root Cause

Two main reasons: insufficient heap memory (default 512 MB–1 GB) and frequent re‑indexing of large directories such as node_modules.

Solution

Increase IDEA heap size by editing idea64.exe.vmoptions (or /Applications/IntelliJ IDEA.app/Contents/bin/idea.vmoptions) with the following settings for an 8 GB machine:

# Recommended configuration for 8 GB RAM
-Xms2048m   # initial heap
-Xmx4096m   # maximum heap
-XX:ReservedCodeCacheSize=512m
-XX:+UseG1GC
-XX:+UseStringDeduplication

Exclude unnecessary directories (e.g., node_modules, .git, target, build) via File → Settings → Project Structure → Modules → Excluded .

After these steps the IDE feels much smoother.

Pitfall 2: Lombok‑generated getters/setters show red errors

Symptoms

After updating IDEA or changing a configuration, classes annotated with @Data or @Getter show red underlines and compilation fails with “cannot find getXxx method”.

Root Cause

Lombok generates code at compile time via an annotation processor. IDEA needs the Lombok plugin and annotation‑processing enabled.

Solution

Install and enable the Lombok plugin ( File → Settings → Plugins → Lombok ).

Enable annotation processing ( File → Settings → Build, Execution, Deployment → Compiler → Annotation Processors → Enable annotation processing ).

Ensure the project’s pom.xml or build.gradle contains a recent Lombok dependency, e.g.

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.18.30</version>
  <scope>provided</scope>
</dependency>

If the problem persists, invalidate caches ( File → Invalidate Caches / Restart ) and delete the .idea folder to let IDEA regenerate configuration.

Pitfall 3: Debug breakpoints are ignored

Symptoms

Breakpoints placed in a service method never stop execution; sometimes the breakpoint icon is gray.

Root Cause

Breakpoint placed on a non‑executable line (interface method, empty line, comment).

Breakpoint disabled (icon has a slash).

Code optimized away by JIT in release mode.

Conditional breakpoint condition always false.

Solution

Verify the breakpoint icon is solid red; if it has a slash, right‑click and enable it.

Make sure the breakpoint is on an executable line, e.g. after the opening brace of a method.

Check that no “Disable all breakpoints” option is active (Ctrl + Shift + F8 opens the breakpoint manager).

For conditional breakpoints, ensure the condition can become true.

If still failing, print the stack trace with Thread.currentThread().getStackTrace() or use log statements.

Pitfall 4: Console shows garbled Chinese characters

Symptoms

Running a program prints “???” or Unicode escapes like \uXXXX instead of Chinese text.

Root Cause

Encoding mismatch among source files, IDEA console, JVM default encoding, and OS.

Solution

Set all project files to UTF‑8: File → Settings → Editor → File Encodings → Global Encoding = UTF‑8, Project Encoding = UTF‑8, Default encoding for properties files = UTF‑8 and enable “Transparent native‑to‑ASCII conversion”.

Add JVM options -Dfile.encoding=UTF-8 and -Dconsole.encoding=UTF-8 via Help → Edit Custom VM Options .

For Maven projects, configure project.build.sourceEncoding and project.reporting.outputEncoding to UTF‑8 in pom.xml.

If using Logback or Log4j, set the charset of the console appender to UTF‑8.

Pitfall 5: Unwanted .idea files appear in Git commits

Symptoms

IDEA’s Commit Changes dialog shows files like .idea/workspace.xml, .iml, or compiled target/ files.

Root Cause

The .idea directory and IDE‑generated files are tracked by default, and no .gitignore is present.

Solution

Create a .gitignore at the repository root with entries such as:

# Compiled class files
*.class
target/
out/

# IntelliJ IDEA
.idea/
*.iml
*.iws
*.ipr
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/compiler.xml
.idea/libraries/

In IDEA, open Settings → Version Control → Ignored Files to ensure the rules are applied.

If the .idea folder was already committed, remove it from the index:

git rm -r --cached .idea
git commit -m "Remove .idea from git"

Pitfall 6: Maven dependencies download extremely slowly

Symptoms

Refreshing Maven projects shows a spinning indicator, often timing out with “Transfer failed” or “Read timed out”.

Root Cause

Maven’s default central repository is overseas, causing high latency, and IDEA may use the default settings.xml without a mirror.

Solution

Create or edit a user settings.xml and add a domestic mirror, e.g. Alibaba Cloud:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" ...>
  <mirrors>
    <mirror>
      <id>aliyunmaven</id>
      <mirrorOf>central</mirrorOf>
      <name>Alibaba Cloud Public Repository</name>
      <url>https://maven.aliyun.com/repository/public</url>
    </mirror>
  </mirrors>
</settings>

In IDEA go to File → Settings → Build, Execution, Deployment → Build Tools → Maven → User settings file and point to the custom settings.xml.

Disable “Work offline” and enable “Import Maven projects automatically”.

If the network is still poor, configure an HTTP proxy under Settings → Appearance & Behavior → System Settings → HTTP Proxy .

Pitfall 7: Code compiles but fails at runtime (ClassNotFoundException)

Symptoms

Running mvn clean compile succeeds, but launching the application throws java.lang.ClassNotFoundException.

Root Cause

IDEA’s compiler output directory differs from Maven’s ( out/ vs target/classes), or the Lombok annotation processor didn’t generate code.

Solution

Enable “Build project automatically” ( File → Settings → Build, Execution, Deployment → Compiler ).

Check each module’s output paths via File → Project Structure → Modules and set them to target/classes and target/test-classes for Maven projects.

Rebuild the project ( Build → Rebuild Project ) and, if needed, invalidate caches ( File → Invalidate Caches / Restart ).

Pitfall 8: Keyboard shortcuts stop working

Symptoms

Common shortcuts like Ctrl +C, Ctrl +V, or Ctrl +Alt +L no longer perform their expected actions.

Root Cause

Conflicts with other applications (e.g., WeChat, Sogou input method, QQ).

IDEA keymap was unintentionally changed.

Solution

Open File → Settings → Keymap and verify the selected keymap (Default or Mac OS X). Use “Restore Defaults” if it was altered.

Disable or reassign conflicting shortcuts in external software.

Search for a specific shortcut in the Keymap dialog to see if it’s overridden and remove the conflict.

Pitfall 9: Unable to connect to MySQL from IDEA’s Database tool

Symptoms

Connection errors such as “The server time zone value '???' is unrecognized” or “Could not create connection to database server”.

Root Cause

MySQL 8+ requires an explicit serverTimezone parameter; IDEA’s default URL omits it.

Solution

In the Database datasource settings, open the “Advanced” tab and add:

Name: serverTimezone
Value: Asia/Shanghai   // or UTC

Alternatively, append the parameter to the JDBC URL, e.g.:

jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf-8

Ensure the MySQL driver version matches the server (use an older driver for MySQL 5.7 if needed).

Pitfall 10: Automatic code reformatting on commit changes the whole file

Symptoms

Before committing, IDEA reformats the file, causing massive diffs even for a single line change.

Root Cause

IDEA’s “Reformat code”, “Optimize imports”, and “Rearrange code” options are enabled for commits, and team members may have different formatting rules.

Solution

Two approaches:

Standardize formatting : Add a .editorconfig file to the project root with common rules (e.g., UTF‑8, 4‑space indent). IDEA will detect and apply it. Export the IDEA code‑style settings and share them via version control.

Disable automatic reformatting : Go to File → Settings → Version Control → Commit and uncheck “Reformat code”, “Optimize imports”, and “Rearrange code”.

Conclusion

IntelliJ IDEA is a powerful IDE, but misconfigurations can quickly turn it into a hindrance. By adjusting memory settings, managing indexing, configuring plugins, fixing encoding, using proper .gitignore rules, adding Maven mirrors, aligning compiler output, resolving shortcut conflicts, setting MySQL time zones, and controlling automatic formatting, developers can keep the IDE fast, reliable, and productive.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaPerformanceGitmavenIntelliJ IDEAIDE
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.