maven的安装和eclipse的配置以及构建mahout基本项目

来源:互联网 发布:ifconfig修改mac地址 编辑:程序博客网 时间:2024/04/30 09:26

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已经配置好了



用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基本项目完成

0 0
原创粉丝点击