天天看點

maven的安裝和eclipse的配置以及建構mahout基本項目

版權聲明:本文為部落客原創文章,未經部落客允許不得轉載。 https://blog.csdn.net/qq1010885678/article/details/45175325

maven介紹在此略過

下載下傳位址:

點選打開連結

windows下載下傳xxx-bin.zip檔案

linux下載下傳xxx-bin.tar.gz

這裡以windows為例

下載下傳完成直接解壓到一個目錄下

計算機--右鍵--屬性--進階系統設定--環境變量--在系統變量中建立M2_HOME,值為maven解壓的路徑

在系統變量PATH中新增,%M2_HOME%\bin

注意反斜杠用;和其他值分隔開

配置好之後打開cmd輸入mvn -version就可以看到maven的相關資訊(如果提示找不到mvn的話重新開機一下電腦試試)

在eclipse中安裝maven插件

打開eclipse,在菜單欄中選擇help--install new software

add添加,輸入下面的網址

http://download.eclipse.org/technology/m2e/releases/

點選ok,檢查完畢之後點選next開始下載下傳安裝

安裝完成之後在eclipse中的window--preferences找到maven--user settings--路徑填上maven目錄下conf\settings.xml檔案路徑

maven的安裝和eclipse的配置以及建構mahout基本項目

現在maven已經配置好了

用maven建構mahout基本項目

在cmd指令行中執行

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DgroupId=org.conan.mymahout -DartifactId=myMahout -DpackageName=org.conan.mymahout -Dversion=1.0-SNAPSHOT -DinteractiveMode=false

這段指令會在目前的路徑下建立一個名為myMahout的項目(執行過程中可能會出錯,可能是缺失某些jar包導緻的,檢視具體錯誤資訊,下載下傳具體的jar包就可以,例如缺少的是一個maven-archetype-quickstart-1.0.jar  到http://mirrors.ibiblio.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.0/下載下傳完成之後放到maven安裝路徑下的lib目錄下,在指令行執行mvn install:install-file

-DgroupId=org.apache.maven.archetypes -DartifactId=maven-archetype-quickstart -Dversion=1.1 -Dpackaging=jar -Dfile=maven-archetype-quickstart-1.0.jar   之後再建立項目就ok)

成功的結果如下:

将項目導入eclipse:

使用import--maven--existing maven projects

選擇建立好的項目檔案夾即可

修改pom檔案:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<span style="white-space:pre">	</span>xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<span style="white-space:pre">	</span><modelVersion>4.0.0</modelVersion>
<span style="white-space:pre">	</span><groupId>org.conan.mymahout</groupId>
<span style="white-space:pre">	</span><artifactId>myMahout</artifactId>
<span style="white-space:pre">	</span><packaging>jar</packaging>
<span style="white-space:pre">	</span><version>1.0-SNAPSHOT</version>
<span style="white-space:pre">	</span><name>myMahout</name>
<span style="white-space:pre">	</span><url>http://maven.apache.org</url>
<span style="white-space:pre">	</span><properties>
<span style="white-space:pre">		</span><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<span style="white-space:pre">		</span><mahout.version>0.6</mahout.version>
<span style="white-space:pre">	</span></properties>


<span style="white-space:pre">	</span><dependencies>
<span style="white-space:pre">		</span><dependency>
<span style="white-space:pre">			</span><groupId>org.apache.mahout</groupId>
<span style="white-space:pre">			</span><artifactId>mahout-core</artifactId>
<span style="white-space:pre">			</span><version>${mahout.version}</version>
<span style="white-space:pre">		</span></dependency>
<span style="white-space:pre">		</span><dependency>
<span style="white-space:pre">			</span><groupId>org.apache.mahout</groupId>
<span style="white-space:pre">			</span><artifactId>mahout-integration</artifactId>
<span style="white-space:pre">			</span><version>${mahout.version}</version>
<span style="white-space:pre">			</span><exclusions>
<span style="white-space:pre">				</span><exclusion>
<span style="white-space:pre">					</span><groupId>org.mortbay.jetty</groupId>
<span style="white-space:pre">					</span><artifactId>jetty</artifactId>
<span style="white-space:pre">				</span></exclusion>
<span style="white-space:pre">				</span><exclusion>
<span style="white-space:pre">					</span><groupId>org.apache.cassandra</groupId>
<span style="white-space:pre">					</span><artifactId>cassandra-all</artifactId>
<span style="white-space:pre">				</span></exclusion>
<span style="white-space:pre">				</span><exclusion>
<span style="white-space:pre">					</span><groupId>me.prettyprint</groupId>
<span style="white-space:pre">					</span><artifactId>hector-core</artifactId>
<span style="white-space:pre">				</span></exclusion>
<span style="white-space:pre">			</span></exclusions>
<span style="white-space:pre">		</span></dependency>
<span style="white-space:pre">	</span></dependencies>
</project>

           

将以上配置複制到pom檔案中

由于配置中删除了junit依賴包是以會報錯,隻要将test的那個包删除即可

maven建構的mahout基本項目完成