Eclipse中用Git导入Maven项目

导入项目

1.右键 > Import > Project from Git

7751482896_de4553ea44

2.选择URI

7751485316_32100db2a8

3.输入Remote Git Repo的配置信息

7751485600_3e49558fcc

注意:Protocol使用ssh, User使用git, Password为账户在github的密码

4.查找远程分支信息

7751487764_9f1dd6693e

5.选择分支

7751487672_349d53df23

6.选择本地目标位置

7751487578_b00ff456cd

7.从版本仓库中进行Clone

7751498510_8312c87557

8.接受文件中

7751487370_9019a23670

9.选择导入项目类型

7751487280_4db494edaa

注意: 选择Import as general project

10.确认项目名称

7751487202_11afc22fac

11.项目如下

7751487104_ea521356da

注意: 此时项目为General Project不是Maven project, 需要手工修改配置文件。但是由[druid master]可以看出,已经是一个带版本控制的项目了。

修改项目配置文件

由于导入的是普通项目,需要转化成Maven Project。Eclipse中项目的主要配置文件是.classpath和.project,还有.settings文件夹。
原项目为General project, 只有.project文件,其.project配置文件内容如下

<?xml version=”1.0″ encoding=”UTF-8″?>
<projectDescription>
<name>druid</name>
<comment></comment>
<projects></projects>
<buildSpec></buildSpec>
<natures></natures>
</projectDescription>

需要修改.project,并添加.classpath文件:

<?xml version=”1.0″ encoding=”UTF-8″?>
<projectDescription>
<name>druid</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

还有.classpath文件

<?xml version=”1.0″ encoding=”UTF-8″?>
<classpath>
<classpathentry kind=”src” output=”target/classes” path=”src/main/java”>
<attributes>
<attribute name=”optional” value=”true”/>
<attribute name=”maven.pomderived” value=”true”/>
</attributes>
</classpathentry>
<classpathentry excluding=”**” kind=”src” output=”target/classes” path=”src/main/resources”>
<attributes>
<attribute name=”maven.pomderived” value=”true”/>
</attributes>
</classpathentry>
<classpathentry kind=”src” output=”target/test-classes” path=”src/test/java”>
<attributes>
<attribute name=”optional” value=”true”/>
<attribute name=”maven.pomderived” value=”true”/>
</attributes>
</classpathentry>
<classpathentry excluding=”**” kind=”src” output=”target/test-classes” path=”src/test/resources”>
<attributes>
<attribute name=”maven.pomderived” value=”true”/>
</attributes>
</classpathentry>
<classpathentry kind=”con” path=”org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5″>
<attributes>
<attribute name=”maven.pomderived” value=”true”/>
</attributes>
</classpathentry>
<classpathentry kind=”con” path=”org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER”>
<attributes>
<attribute name=”maven.pomderived” value=”true”/>
</attributes>
</classpathentry>
<classpathentry kind=”output” path=”target/classes”/>
</classpath>

刷新项目

在项目上右键 > Refresh.
如果还有错误,可以在项目上右键 > Maven > Update project.. > OK, Eclipse 会自动重新建立.settings文件夹。

7751487032_069bd7545c

此时项目完成,可以直接提交到Git了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值