[英]How to add maven dependencies to Scala project
I'm doing a research project and i need to use this project written in Scala . 我正在做一个研究项目,我需要使用用Scala编写的项目 。
With eclipse i have created a scala project in which i put the HELLO CAPS code. 使用eclipse,我创建了一个scala项目,在其中放入了HELLO CAPS代码。
however the project needs maven dependencies to be set : 但是该项目需要设置Maven依赖项:
<dependency>
<groupId>org.opencypher</groupId>
<artifactId>spark-cypher</artifactId>
<version>0.1.5</version>
My question is how to set this maven dependencies in this Scala project ? 我的问题是如何在此Scala项目中设置该Maven依赖项?
1) create a project-folder with pom.xml
in it. 1)创建一个包含
pom.xml
的项目文件夹。
Example; 例;
mkdir my-project
cd my-project
touch pom.xml
2) Then add dependencies to pom.xml
2)然后将依赖项添加到
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. 3)就是这样。 Then you can run
mvn clean compile
from root of your project, which will download dependencies for you. 然后,您可以从项目的根目录运行
mvn clean compile
,这将为您下载依赖项。
Example: 例:
mvn clean compile
You can see the downloaded dependencies in local maven repo; 您可以在本地Maven存储库中看到下载的依赖项;
$ 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. 4)现在,您可以使用eclipse或intellij导入项目。 (You can skip step 3 as IDEs can do
mvn clean compile
for you as well) (您可以跳过第3步,因为IDE也可以为您执行
mvn clean compile
)
Also read: create a new maven hello-world project 另请阅读: 创建一个新的Maven hello-world项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.