You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用guava-23.6-jre.jar出现NoSuchMethodError报错求助

Fixing NoSuchMethodError: com.google.common.collect.ImmutableList.toImmutableList() in Guava 23.6-jre

Let's break down what's happening here and walk through fixes tailored to your non-Maven (no pom.xml) IntelliJ project.

This error is almost always caused by Guava version conflict on your classpath. The ImmutableList.toImmutableList() static collector method was added in Guava 21.0. Even though you're using 23.6-jre, there’s likely an older Guava version (20.0 or earlier) being loaded first by the JVM—this old version lacks the method, which is why your setProperty() call on line 39 is failing.

Here’s how to resolve this step-by-step in IntelliJ:

  • Check for duplicate Guava libraries
    Open File > Project Structure (use the shortcut Ctrl+Alt+Shift+S to jump there fast). Switch to the Libraries tab, search for "guava", and look for multiple versions listed. If you spot an older release (like 19.0 or 20.0), select it and click the - button to remove it.

  • Verify Guava 23.6-jre is properly configured
    If 23.6-jre isn’t in the Libraries list, click the + button, select Java, then navigate to your local guava-23.6-jre.jar file and add it. Next, go to the Modules tab, select your project module, switch to the Dependencies tab, and confirm Guava 23.6-jre is listed with no other Guava versions present.

  • Clean and rebuild your project
    Head to the toolbar, click Build > Clean Project, then Build > Rebuild Project. Stale compiled classes can sometimes cause unexpected issues, so this clears them out. Restart IntelliJ afterward to ensure all changes take effect.

  • Double-check your run configuration’s classpath
    Click the run/debug dropdown in the toolbar and select Edit Configurations. Pick your target run config, go to the Classpath tab, and scan for any old Guava jars. Remove them if found—only guava-23.6-jre.jar should be present here.

One extra note: If your project uses third-party libraries, some might bundle an older Guava version. In that case, drag Guava 23.6-jre to the top of the dependencies list in the Modules > Dependencies tab—this tells the JVM to load your preferred version first.

内容的提问来源于stack exchange,提问作者Nick Slavsky

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 09:22:57