Maven可以版主开发完成的工作:
- 构建
- 文档生成
- 报告
- 依赖
- SCMs
- 发布
- 分发
- 邮件列表
Maven安装
- 下载Maven
- 环境变量设置
- 添加 变量到系统“Path”变量
- 验证Maven安装:mvn --version
Maven 仓库
在maven安装目录的conf文件夹的settings.xml
- 本地(local)
<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:/MyLocalRepository</localRepository>
</settings>
- 中央(central)
不需要配置 - 远程(remote)
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
在pom.xml中添加
<repositories>
<repository>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
添加外部依赖
在pom.xml中
<dependency>
<!--指定 groupId 为 library 的名称。-->
<groupId>ldapjdk</groupId>
<!--指定 artifactId 为 library 的名称。-->
<artifactId>ldapjdk</artifactId>
<!--指定作用域(scope)为系统。-->
<scope>system</scope>
<version>1.0</version>
<!--指定相对于工程位置的系统路径。-->
<systemPath>${basedir}\src\lib\ldapjdk.jar</systemPath>
</dependency>
</dependencies>
创建maven工程
- 使用Eclipse
- File > Import > option
- 选择Maven Project