How do I add a Maven dependency in Eclipse?
- On the top menu bar, open Window -> Show View -> Other
- In the Show View window, open Maven -> Maven Repositories
- In the window that appears, right-click on Global Repositories and select Go Into
- Right-click on "central (http://repo.maven.apache.org/maven2)" and select "Rebuild Index"
- Note that it will take very long to complete the download!!!
- Once indexing is complete, Right-click on the project -> Maven -> Add Dependency and start typing the name of the project you want to import (such as "hibernate").
- The search results will auto-fill in the "Search Results" box below.
Missing Maven dependencies in Eclipse project
Problem solved!
I don't know what exactly solved it, but I did 4 things in Eclipse:
- Window->Preferences: Maven->Installations: Global settings -> open file and hardcoded localRepository
- Project->Clean
- right click on project: Maven->Update dependencies
- right click on project: Maven->Update project configuration
I guess it was the Update dependencies since right after first two there were no change.
Adding maven dependencies in eclipse
If you convert your project to maven project pom.xml
will be automatically created,if not
1- Create pom.xml
file -by clicking on project directory->new->file
2- search frm google maven dependencies for ex: if you want to download spring-context.jar ,then search for maven spring context ,you will get groupid
and artifactid
paste it in pom.xml
file.jars will be automatically downloaded.
How to configure Eclipse build path to use Maven dependencies?
If you right-click on your project, there should be an option under "maven" to "enable dependency management". That's it.
How to add Maven Managed Dependencies library in build path eclipse?
from the command line type:
mvn eclipse:eclipse
this will add all the dependencies you have in your pom.xml into eclipse...
however, if you haven't done any of this before you may need to do one other, one time only step.
Close eclipse, then run the following command from the shell:
mvn -Declipse.workspace=<eclipse workspace> eclipse:add-maven-repo
sample:
mvn -Declipse.workspace=/home/ft/workspaces/wksp1/ eclipse:add-maven-repo
How to add maven dependencies to Scala project
1) create a project-folder with pom.xml
in it.
Example;
mkdir my-project
cd my-project
touch pom.xml
2) Then add dependencies to pom.xml
Example,
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.group-name</groupId>
<artifactId>my-project</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>2.12.6</version>
</dependency>
<dependency>
<groupId>org.opencypher</groupId>
<artifactId>spark-cypher</artifactId>
<version>0.1.5</version>
</dependency>
</dependencies>
</project>
3) That should be it. Then you can run mvn clean compile
from root of your project, which will download dependencies for you.
Example:
mvn clean compile
You can see the downloaded dependencies in local maven repo;
$ ls -l ~/.m2/repository/org/opencypher/
total 0
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 ast-9.1
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 expressions-9.1
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 front-end-9.1
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 front-end-parent
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 okapi
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 okapi-api
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 okapi-ir
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 okapi-logical
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 okapi-relational
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 okapi-trees
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 parser-9.1
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 rewriting-9.1
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 spark-cypher
drwxr-xr-x 3 prayagupd 184630988 102 Jul 15 12:53 util-9.1
4) Now you can import your project using eclipse or intellij. (You can skip step 3 as IDEs can do mvn clean compile
for you as well)
Also read:
create a new maven hello-world project
Related Topics
What Is a Covariant Return Type
Hadoop No Filesystem for Scheme: File
How to Hot-Reload Properties in Java Ee and Spring Boot
How to Reference Another Property in Java.Util.Properties
How to Access Resources in Jar File
Spring Java Config: How to Create a Prototype-Scoped @Bean with Runtime Arguments
Jackson Renames Primitive Boolean Field by Removing 'Is'
Mock a Constructor with Parameter
Why Is an Array Not Assignable to Iterable
How to Check That a String Is Parseable to a Double
Convert Java.Time.Localdate into Java.Util.Date Type
What Is More Efficient: System.Arraycopy or Arrays.Copyof
Synchronizing on an Integer Value
No-Throw Virtualmachineerror Guarantees
Java Webservice Client (Best Way)
How to Get SQL from Hibernate Criteria API (*Not* for Logging)
Why Does Parallel Stream with Lambda in Static Initializer Cause a Deadlock