使用Maven管理项目jar包

安装Maven
安装Maven之前需要安装JDK。
打开页面选择适合的版本 http://maven.apache.org/download.cgi#

检查Java环境变量

echo %JAVA_HOME%
C:\Program Files\Java\jdk1.7.0_51

添加Maven环境变量

MAVEN_HOME=E:\apache-maven-3.5.0
MAVEN_OPTS=-Xms1G -Xmx3G -XX:PermSize=256m -XX:MaxPermSize=520M

在path变量末尾加入%MAVEN_HOME%\bin

测试Maven环境变量

echo %MAVEN_HOME%
E:\apache-maven-3.5.0
echo %MAVEN_OPTS%
-Xms1G -Xmx3G -XX:PermSize=256m -XX:MaxPermSize=520M

mvn -v
Java HotSpot(TM) Client VM warning: ignoring option PermSize=256m; support was removed in 8.0
Java HotSpot(TM) Client VM warning: ignoring option MaxPermSize=520M; support was removed in 8.0
Error occurred during initialization of VM
Could not reserve enough space for 3145728KB object heap

到这一步就安装成功了。

配置Maven

我的Maven 目录是 E:\apache-maven-3.5.0
repository目录是 E:\m2\repository
repository目录会下载很多文件就是maven从中央仓库下载到本地仓库的文件
修改 maven\conf\setting.xml



<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

    
  <localRepository>E:/m2/repositorylocalRepository>

   <mirrors>
    
 <mirror>
      <id>centralid>
      <name>Maven Repository Switchboardname>
      <url>http://repo1.maven.org/maven2url>
      <mirrorOf>centralmirrorOf>
    mirror>
       mirrors>
  <pluginGroups>

  pluginGroups>

  <proxies>

  proxies>


  <servers>

  servers>

  <profiles>

    <profile>
        <id>thinkgemid>
    profile>
  profiles>

  <activeProfiles>
    <activeProfile>thinkgemactiveProfile>
  activeProfiles>
settings>

拷贝一个setting.xml 到E:\m2\repository

你可能感兴趣的:(Java)