'Can't import dependencies that have been downloaded to .m2
I'm importing dependencies via Maven:
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.4-1203-jdbc4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
I checked C://Users/user/.m2/repository and I can see those dependencies in .jar files in respective folders/packages. However when I try to import those in code:
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
I get Cannot resolve symbol error:
I tried;
mvn clean
mvn install
mvn clean install
I get compile error on mvn install. I tried removing all source code fromt he project and then mvn install, it resulted in Build Success, however once the source code is added, I can't use the dependency classes.
Solution 1:[1]
This answer helped me. Turned out the dependencies Maven downloaded were assigned a Run time scope (whose idea was to invent this useless error-prone scope??). I set the scope to compile (File - Project structure - Modules - Dependencies - Scope) and it works fine.
Solution 2:[2]
Something is wrong you should check your project from first:
- maven Repositories in your IDE Updated True?
- run "mvn Clean" in IDE Console
- Reimport All maven Project
- go to pom.xml and check your dependencies.
Good luck.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | The Amateur Coder |
| Solution 2 |

