可以管理项目jar包的构建,解决jar包之间的冲突;可以对项目进行管理,比如项目打包等,maven使用pom项目对象模型进行构建项目的。
简单来说,初学者都需要手动导入jar包的,而Maven是不需要再导入jar包了,那么jar从哪里来呢?就在本地仓库里找,本地仓库没有这个jar包就到远程仓库,比如官方中央仓库,阿里云仓库。
注意:连接远程仓库必须要有网
1. 项目jar包的构建
2. 项目的管理(项目生命周期的管理)
比如:打包,javase项目打jar,javaweb项目打成war包,还有其他功能
3. 分模块开发(聚合项目)
使用maven管理依赖jar包,以后就不用复制jar包到项目中了,那么maven从仓库获取jar包进行构建项目呢
官方中央仓库地址:http://repo1.maven.org/maven2/
第三方阿里云仓库:http://maven.aliyun.com/nexus/content/groups/public/
注意,阿里云不对浏览器访问开放
可以在pom.xml配置坐标信息,坐标信息用于指向仓库里面具体jar包的位置,引用jar包给项目去构建
groupId,对应仓库里面第一层目录
artifactId,对应仓库里面第二层目录
version,对应仓库里面第三层目录
例子,引用junit的jar包使用坐标来描述,这个描述会放到pom.xml文件中
<dependency> <!--依赖-->
<groupId>junit</groupId> <!--组织名,仓库里面的第一层目录-->
<artifactId>junit</artifactId> <!--项目名-模块名, 仓库里面的第二层目录-->
<version>4.12</version> <!--版本号, 仓库里面的第三层目录-->
<scope>test</scope>
</dependency>
本地仓库的jar包位置
注意的点:大多数每个坐标的组成都对应一层目录,只有groupId特殊,如果groupid描述的信息中有“.”,就会代表多层目录结构
官网地址:http://maven.apache.org/download.cgi
maven服务器的目录结构
解压到某个盘(小编解压的C盘)
通过路径settings.xml(全局配置文件)
<?xml version="1.0" encoding="UTF-8"?>
<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>C:\webServer\repository</localRepository>
<pluginGroups></pluginGroups>
<proxies></proxies>
<servers></servers>
<!--网络仓库位置-->
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<!--配置全局的jdk编译语言级别版本(如果不配这个,默认编译级别是1.5,太低,idea运行的会有警告)-->
<profile>
<id>development</id>
<activation>
<jdk>1.8</jdk>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
</settings>
注意:有很多注释的,小编全删除了,让大家方便好看点
配置环境
设置环境变量
文章评论