Intellij IDEA 与 Maven

按常规方法安装好。
第一次启动,需要选择 导入之前配置文件 或者 自己新建。
具体方法附带的压缩包里有。
注意点:
1.安装好之后,会产生如下目录: C:\Users\Administrator.2013-20160529SU.IntelliJIdea13\config
如果之前有安装过,配置过的话,会有一个setting.jar文件在此目录下。
新安装时,可以选择导入这个jar. file->import setting ,但是这里只能导入一些样式,字体,主题风格等信息,至于插件配置等根本就没有。
2.创建maven项目
pom.xml 配置文件写明依赖jar包,maven 本地仓库默认路径在:C:\Users\Administrator.2013-20160529SU.m2\repository,在 pom.xml 写一个依赖a.jar, 会首先在该路径下找,如果有的话,直接用上,没有的话,联网下载到该路径下。
那么问题来了,通常一个项目需要用到许许多多jar,如果把仓库建立在C盘,那么随着jar越来越多,C盘可能难以承受。
还有一个问题是,在联网下载的时候,镜像在国外的话下载速度慢。
解决办法是,找到C:\Users\Administrator.2013-20160529SU.m2 下的settins.xml文件,修改:

<!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
   -->
  <localRepository>F:\StudySoft\apache-maven-3.2.1-config\repository</localRepository>
   <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
     <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>

    </mirrors>

maven 真的是好方便,在挂网下载一个包,解压到某个目录下,然后配置好环境变量M2_HOME,然后在IDEA里边关联一下,写好pom.xml就可以用了。
以前手动导jar包的问题有:
1.多个项目使用一套相同的jar包,不能共用,必须得复制一份,占空间。
2.jar包不用自己找啦,卸载pom.xml里面让工具自己下载放好就行了。

2017-02-14更新——————————————–

比较全的步骤
http://blog.csdn.net/qq_32588349/article/details/51461182
如果报错: -Dmaven.multiModuleProjectDirectory system propery is not set. Check M2HOMEenvironmentvariableandmvnscriptmatch.file>settings>maven>runner>VMDmaven.multiModuleProjectDirectory= M2_HOME

然后重新导入项目,编辑pom.xml
后,点import change
即可。

2017-2-21 更新———————————————–
今天用eclipse新建maven工程,写pom.xml时,总是出错。
错误信息:ArtifactDescriptorException

原因:我在 eclipse 中配置maven环境的时候,选择settings.xml目录的时候没有改,用的默认地址(C:\Users\35047.m2\settings.xml).
然而安装maven的时候改了地址,装在D:\学习工具软件\maven\apache-maven-3.3.9,
D:\学习工具软件\maven\apache-maven-3.3.9\conf\settings.xml这才是我需要的设置文件。
在eclipse中改过来就OK了。
还有 ,我猜过可能是这个地方出错,但是想当然觉得没问题,所以,以后遇到疑点要去试一下~

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值