首页 > 解决方案 > Maven + IDEA: cannot find String

问题描述

I am trying out the workflow where you create and maintain your project primarily in Maven, and the Intellij IDEA project files are derived from that, which seems to be the recommended way these days.

My setup: Windows 7, JDK 11, Maven 3.6.0, IDEA Community 2018.2.6, the latter three all fairly fresh installs, not messed around with, verified as working in their own right.

https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html followed steps to create a Hello World project, verified it compiles and runs with Maven after adding the project property entries to specify we are not on Java 5 anymore.

Opened the project in IDEA by opening pom.xml and saying yes, this is a project file.

Opened App.java, and references to String are underlined in red: Cannot resolve symbol 'String'.

Tried invalidate caches / restart, no change.

Consensus as far as I can tell is that maven is the top build system and IDEA is the top IDE, so it must be possible to get them to work together. How?

标签: javamavenintellij-idea

解决方案


打开Project Structure(按F4):

在此处输入图像描述

检查SDKsProblems部分是否有任何错误。


推荐阅读