IntelliJ IDEA and Gradle - Cannot be applied to &#

2020-05-22 04:27发布

I have a Gradle file which, whenever I load open it in IntelliJ IDEA 14.1.5, shows IDE errors for the entire file. Namely all the errors seem to be either:

java.lang.String errors

java.lang.String errors

or

groovy.lang.Closure errors

groovy.lang.Closure errors

I've tried clearing the file's contents and only writing the top line:

group 'com.me.blah'

but even that results in an error.

For context's sake - this is an individual module in a larger SpringBoot project. This module is a set of simple static files (with Gradle for CSS compilation, static analysis, etc), while the rest are Java modules, and are not having Gradle issues.

Can anyone think why IntelliJ would be struggling to understand this Gradle file?

8条回答
Evening l夕情丶
2楼-- · 2020-05-22 04:57

For me, after trying out all this answers without result, changing the Java SDK of the project did the trick, I was on 1.8 and changed it to the newest one, but still a project level language of 8.

Hope this helps!

查看更多
我欲成王,谁敢阻挡
3楼-- · 2020-05-22 05:02

Happened to me recently on windows. I tried all of the above but it didn't work.

What i did:

1 - I had JAVA_HOME environment variable already set. So IDEA picked that as project SDK and these warnings showed up.

2 - So, i removed the default JAVA_HOME from project SDK and manually added jdk path. Restarted and all warning were gone.

Maybe it will help someone. Thanks.

查看更多
登录 后发表回答