提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
一、现象
IDEA启动springboot项目,提示java: java.lang.IllegalArgumentException,没有多余的信息,百度之后都是让修改idea的Java compiler,但是我全都设置的Java8,所以没头绪。
二、解决方法
1.问题进一步描述
谷歌搜了一下,发现Jetbrains的官网有人提这个问题,大致浏览了下,描述和我的问题一致。再看描述产生这个问题的条件:简单描述下,就是IDEA 2020.3版本会复现这个问题,如果升级到2020.4就没有该问题,而且后面的添加提问是说2020.3.1.RC版本也会有这个问题。
链接在这儿:https://youtrack.jetbrains.com/issue/IDEA-256707
What steps will reproduce the issue?
1. Upgrade to 2020.3 invalidate caches and restart
2. Build Project (Ctlr+F9)
3. Build output shows java: java.lang.IllegalArgumentException without any clue what's wrong // 注意这一句,这个IllegalArgumentException和其他的不同,所以百度搜到的解决方法不能解决该问题
4. Downgrade to 2020.2.4 invalidate caches and restart
5. Build Project (Ctrl+F9)
6. Build succeeds
java -version
openjdk version "1.8.0_275"
OpenJDK Runtime Environment (build 1.8.0_275-b01)
OpenJDK 64-Bit Server VM (build 25.275-b01, mixed mode)
Stack trace:
2020-12-02 18:03:52,635 [ 4497] INFO - s.incremental.java.JavaBuilder - java.lang.IllegalArgumentException
java.lang.RuntimeException: java.lang.IllegalArgumentException
at com.sun.tools.javac.main.Main.compile(Main.java:553)
at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:231)
at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:498)
at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:350)
at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:274)
at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:228)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1441)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1100)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1224)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1066)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:832)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:419)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:183)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:302)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:132)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:219)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
2. 解决方法
- 更换IDEA的版本,改成非2020.3和非2020.3.1.RC
- 不修改IDEA版本,通过配置参数让IDEA跳过一些检查(具体的可以看上面发的链接里的解释,不过好像不是很推荐)。修改参数的方法如下:在Build, Execution, Deployment > Compiler add to the Shared build process VM options设置 -Djps.track.ap.dependencies=false, 截图如下
总结
- idea也是有bug的
- 百度不好用的时候,别忘了试试Google