问题
After importing a newly created Vaadin 14.0.x project, and using the Import Project
feature to create a Maven-driven project in IntelliJ 2019.3 EAP, I get a message saying "Cannot resolving symbol". The error message offers me a button to "Add library … to classpath". But the necessary libraries are already loaded by Maven as dependencies. So this makes no sense.
I retried the import 3 times. On each effort I opened another project to run the File
> Invalidate Caches / Restart
menu item. This action avoids known IntelliJ bugs/anti-features with creating a new project with same name as a deleted project.
Eventually I tried using the Open
feature of the "Welcome to IntelliJ IDEA` panel. Amazingly, no such problem. All the classes are recognized by the IntelliJ code editor.
Bizarre, as I am opening each time a fresh unzipped copy of the original project created by the Getting Started with Vaadin page. There is some major difference between using Open
versus Import Project
in IntelliJ.
回答1:
The best advice is "dont use the Import Project" feature. It's always been a little buggy / cumbersome ;)
Simply check out your project, and open the project's root folder (containing the parent pom.xml
) in IntelliJ.
Incidentally, after checking out from git, the "Would you like to open this project in IntelliJ?" has also been buggy in the past. As a habit I answer "no" to this question and use File -> Open to open the new project manually.
回答2:
Avoid Create project from existing sources
option
I suspect that when you chose the Import Project
route, you accepted the default option in the resulting dialog box. Do not use that option.
❌
That option, Create project from existing sources
will fail in your situation. The documentation for that dialog unfortunately does not explain the first item. But option seems to expect a fully-formed project folder. Yours is not, apparently.
Use Import project from external model
option
Instead, choose the second option, Import project from external model
. Select Maven
from the list, in your case, for a Vaadin 14 project.
✅
Note that with this option, you go through a series of dialogs Wizard-style. Whereas, with the first option, you directly opened the project.
Using this second option, and completing the series of dialogs, will yield an operational Vaadin 14 project.
来源:https://stackoverflow.com/questions/58987498/after-importing-a-maven-project-into-intellij-2019-3-the-bundled-classes-are-no