Dependency 'mysql:mysql-connector-java:8.0.29' not found

Viewed 538

enter image description here

I have added jar file on the left side. But it still has error. How to solve it?

2 Answers

The dependencies are red because Maven cannot find them in your local cache. Unless you've turned auto-reload on, you need to Reload the Maven Project when you make changes to the POM to have IntelliJ pick them up. Once IntelliJ has been reloaded, it will automatically attempt to resolve the artifacts, at which point the error should go away.

You can reload by opening the "Maven" window (by default on the right side pane), then clicking the "Reload All Maven Projects" button.

Then wait for the reload to complete.

As a note, Maven is a build automation tool which is meant to manage dependencies for you. Adding them directly through IntelliJ circumvents that. If you're using Maven it's generally preferable not to add additional dependencies like that unless you intend for it to only work that way on your local machine.

Sometimes I find that IntelliJ has issues with dependencies.

When it does, I immediately go to the File menu and find Invalidate Caches and Restart. This usually fixes whatever issues I might have with Maven dependencies.

Related