Intelij IDEA配置Maven Git

本文经如下文章总结而来,对此表示感谢:

http://schy-hqh.iteye.com/blog/1950126

https://zhuanlan.zhihu.com/p/28133184

https://blog.csdn.net/gnail_oug/article/details/72783474

https://blog.csdn.net/qq_32588349/article/details/51461182

一.配置Maven

1.安装Maven

前往https://maven.apache.org/ 下载安装包,解压到相应位置后,

新建系统变量 MAVEN_HOME

MAVEN_HOME = D:\Portable Programs\apache-maven-3.5.4

将 ;%MAVEN_HOME%\bin 添加到系统变量PATH末尾

PATH =  ... ;%MAVEN_HOME%\bin

2.修改Maven仓库位置(非必需)

Maven从远端仓库下载的jar文件保存于localRepository中,localRepository在windows下默认为windows用户目录下,如果想修改:

打开 D:\Portable Programs\apache-maven-3.5.4\conf\setting.xml 

找到localRepository设置,

  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

将localRepository设置为自定义目录即可.

<localRepository>D:/repository</localRepository>

可以使用如下命令验证修改是否成功:

mvn help:system

执行成功后,能看到D:\repository 下多了许多下载下来的jar

注意: setting.xml在用户目录下也存在,只针对当前windows用户生效. 用户设置优先于全局设置

3.配置Maven私有仓库地址(非必需)

配置私有仓库地址可以在settings.xml 或 pom.xml里面配置

settings.xml则全局生效,pom.xml里面则针对项目生效. pom.xml能覆盖settings.xml里面的配置,更为灵活

在settings.xml里面配置示例:

先在profiles标签组里面添加一个profile,指向私有仓库,然后在activeProfiles标签组里面激活改profile

<settings>  
  
  ...  
  
  <profiles>  
     <!-- 声明一个id为env-dev的profile -->
     <profile>  
      <id>env-dev</id>  
  
      <repositories>  
        <repository>  
          <id>nexus</id>  
          <url>http://localhost:8081/nexus/content/groups/public/</url>  
          <snapshots><enabled>true</enabled></snapshots>  
          <releases><enabled>true</enabled></releases>  
        </repository>  
      </repositories>  
      <pluginRepositories>  
        <pluginRepository>  
          <id>nexus</id>  
          <url>http://localhost:8081/nexus/content/groups/public/</url>  
          <snapshots><enabled>true</enabled></snapshots>  
          <releases><enabled>true</enabled></releases>  
        </pluginRepository>  
      </pluginRepositories>  
    </profile>  
  </profiles>  
  
  <!-- 激活上面声明的profile -->
  <activeProfiles>
      <activeProfile>dev</activeProfile>
  </activeProfiles> 
  
</settings>

settings.xml详解参考:

https://blog.csdn.net/u012152619/article/details/51485152

http://www.cnblogs.com/jingmoxukong/p/6050172.html

pom.xml详解参考:

https://blog.csdn.net/u012152619/article/details/51485297

4.打开 Intelij IDEA的 settings,在左上角搜索框输入Maven,分别设置Maven 安装目录, settings.xml文件位置,Maven repository目录位置:

如果喜欢看源码,可以勾选 Sources 和Documentation两个选项:

二:Intelij IDEA配置Git

1.前往 https://git-scm.com/download/win 下载Git客户端并安装之;

2.Intelij IDEA -Settings,输入Git,将Path to Git excutable设置为Git安装目录:

更新:

在File-Other Settings-Other Settings for New Projects里修改的设置为全局生效.

猜你喜欢

转载自blog.csdn.net/nianbingsihan/article/details/82763229