首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Eclipse开发 >

MyEclipse 6.5上Maven的安装

2012-10-26 
MyEclipse 6.5下Maven的安装在MyEclipse6.5中实际上已经通过MyElipse插件集成了Maven,但是我在使用的过程

MyEclipse 6.5下Maven的安装

在MyEclipse6.5中实际上已经通过MyElipse插件集成了Maven,但是我在使用的过程中感觉用的不怎么好,例如想通过视图查看各种jar包的依赖关系都看不了,因为其中好像确守POM编辑器,只能用xml的方式打开,因此从网上查了些资料,整理了下。

?

首先,我们需要删除原来MyEclpse中存在的插件,例如像MyEclipse插件目录下的Maven的插件目录也就是在myeclipse\eclipse\features 的相关文件夹和myeclipse\eclipse\plugins目录下的文件夹和对应的jar包,在这里我一一列出

?

myeclipse\eclipse\features目录下的:

?

com.genuitec.myeclipse.maven_6.5.1.zmyeclipse650200806

?

?

?myeclipse\eclipse\plugins目录下的:

?

com.genuitec.myeclipse.maven_6.5.1.zmyeclipse650200806,
org.maven.ide.components.archetype_common_2.0.0.20080331-1600,
org.maven.ide.components.maven_embedder_2.1.0.20080410-2200,
org.maven.ide.components.maven_model_edit_1.0.0.20080331-1600,
org.maven.ide.components.maven_scm_1.0.0.20080410-2200,
org.maven.ide.components.nexus_indexer_1.0.0.20080331-1600,
org.maven.ide.components.qname_1.0.0.20080331-1600,

?

以及相应的jar包:

?

com.genuitec.eclipse.maven_6.5.1.zmyeclipse650200806.jar,
org.maven.ide.eclipse.central_0.9.1.zmyeclipse650200806.jar,
org.maven.ide.eclipse.scm_0.9.2.zmyeclipse650200806.jar,
org.maven.ide.eclipse_0.9.3.zmyeclipse650200806.jar

?

在这里我发现一个一个去找很麻烦,于是自己写了一个类把plugins下的相关jar包文件夹剪切到其他地方

?

package com.lyl.test;import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.util.ArrayList;import java.util.List;public class DelFile {//要剪切的源目录public static final String ResourcePath="D:\\MyEclipse\\MyEclipse 6.5\\myeclipse\\eclipse\\plugins\";//剪切目的文件夹地public static final String destinationPath="D:\\Maven_plguins\";public static void main(String[] args) {File f=new File(ResourcePath);List<String> files=new ArrayList<String>();files.add("com.genuitec.myeclipse.maven_6.5.1.zmyeclipse650200806");files.add("org.maven.ide.components.archetype_common_2.0.0.20080331-1600");files.add("org.maven.ide.components.maven_embedder_2.1.0.20080410-2200");files.add("org.maven.ide.components.maven_model_edit_1.0.0.20080331-1600");files.add("org.maven.ide.components.maven_scm_1.0.0.20080410-2200");files.add("org.maven.ide.components.nexus_indexer_1.0.0.20080331-1600");files.add("org.maven.ide.components.qname_1.0.0.20080331-1600");files.add("com.genuitec.eclipse.maven_6.5.1.zmyeclipse650200806.jar");files.add("org.maven.ide.eclipse.central_0.9.1.zmyeclipse650200806.jar");files.add("org.maven.ide.eclipse.scm_0.9.2.zmyeclipse650200806.jar");files.add("org.maven.ide.eclipse_0.9.3.zmyeclipse650200806.jar"); File [] fs=f.listFiles();for(int i=0;i<fs.length ;i++){f=fs[i];if(files.contains(f.getName())) {String resPath=f.getPath();String disPath=resPath.replace(ResourcePath, destinationPath);if(f.isDirectory()){File fDir=new File(disPath);fDir.mkdir();cute(f);del(f);}else{File from=new File(f.getPath());File to=new File(disPath);try {copy(from,to);del(from);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}}}}//文件夹的剪切方法public static void cute(File f){//在指定位置创建以为文件夹File [] fs =f.listFiles();for(int i=0;i<fs.length ;i++){String dirPath=fs[i].getPath();dirPath=dirPath.replace(ResourcePath, destinationPath);System.out.println(dirPath);if(fs[i].isDirectory()){File fDir=new File(dirPath);fDir.mkdir();cute(fs[i]);del(fs[i]);}else{File from=new File(fs[i].getPath());File to=new File(dirPath);try {copy(from,to);del(from);} catch (Exception e) {// TODO Auto-generated catch blocke.printStackTrace();}}}}public static void  copy(File from ,File to) throws Exception{//构建一个文件输入流对象FileInputStream fin=new FileInputStream(from);//构建以个文件输出流对象FileOutputStream fout=new FileOutputStream(to);//缓冲输入流BufferedInputStream bin=new BufferedInputStream(fin);//缓存输出流BufferedOutputStream bout=new BufferedOutputStream(fout);//定义个字节数组,作为输入流和输出流的中介byte [] b=new byte[2048];//读入的字节长度如果为-1,说明没有内容了    int len=bin.read(b);while(len !=-1){//将字节数组写入输出流中bout.write(b,0,len);len=bin.read(b);}//关闭流,注意顺序bout.close();fout.close();bin.close();fin.close();}public static void del(File from){from.delete();}}

将MyEclipse中的的自带的Maven插件删除后,就可以通过在线安装的方式进行安装需要的Maven插件了:

?

打开Help->Software Updates->Find and Install...->Search for new faatures to install->New Remote Site...
在打开的对话框中输入:
Name:m2eclipse
Url:http://m2eclipse.sonatype.org/sites/m2e/0.10.0.20100209-0800/
安装好maven后在IDE菜单栏点击? window? --> preferences 输入maven
接着点击Installations -->Add? -->选择maven的安装目录 -->Apply
点击User Settings 选择解压后maven下conf文件夹中的settings.xml再点击Apply.

?

就可以完成MyEclipse6.5下Maven插件的安装。

?

?


?

?

热点排行