---
title: "Activiti入门篇之一 Maven环境搭建"
author: "man1900"
date: "2014-04-28T09:09:39Z"
tags: []
categories: ["企业架构"]
slug: "activiti-maven"
draft: false
lastmod: "2018-01-03T17:23:37Z"
id: 2055963
url: "https://man1900.iteye.com/blog/2055963"
---

下载地址[http://maven.apache.org/download.cgi](http://maven.apache.org/download.cgi)

进入该地址，选择其中一二进制发布版本，如：

 

**更多了解**

[**http://redxun.iteye.com/blog/2406509**](/blog/2406509)

![](http://dl2.iteye.com/upload/attachment/0096/5409/1e3e8796-8340-37a1-a5c3-a3be19506edd.png)

**解压maven包**

把maven下载包解压，如下图所示：

![](http://www.activiti.org.cn/data/attachment/forum/201404/26/123555pjj15qd7n6bj76qe.png)  
**修改Settings文件**

```
<?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>E:\maven_rep</localRepository>
  <pluginGroups>
  </pluginGroups>
  <proxies>
  </proxies>
  <servers>
    <server>
     <id>snapshots</id>
     <username>dep</username>
     <password>dep092</password>
    </server>
  </servers>
  <mirrors>
	<mirror>
		<id>nexus</id> 
		<mirrorOf>*</mirrorOf> 
		<url>http://office.jee-soft.cn:8081/nexus/content/groups/hotent/</url>
	</mirror>
  </mirrors>
  <profiles>
	<profile>  
      <id>hotent-remote</id>  
      <repositories>  
		<repository>  
            <id>sonatype</id>  
            <name>sonatype</name>  
            <url>http://repository.sonatype.org/content/groups/public/</url>  
        </repository>
        <repository>  
            <id>hotent-remote</id>  
            <name>remote hotent maven release</name>  
            <url>http://office.jee-soft.cn:8081/nexus/content/groups/hotent/</url>  
        </repository> 
      </repositories>  
    </profile>
  </profiles>
  <activeProfiles>
	<activeProfile>hotent-remote</activeProfile> 
  </activeProfiles>
</settings>
```

 

【说明】

![](http://dl2.iteye.com/upload/attachment/0096/5411/f201d3b9-d764-356e-bbe2-b15bb72a42dd.png)

                   **&lt;localRepository&gt;E:\\maven\_rep&lt;/localRepository&gt;**

2.        更改maven的索引监控地址为：

&lt;mirror&gt;

                   &lt;id&gt;nexus&lt;/id&gt;

                   &lt;mirrorOf&gt;\*&lt;/mirrorOf&gt;

                   &lt;url&gt;[http://office.jee-soft.cn:8081/n ... hotent/&lt;/url&gt;](http://office.jee-soft.cn:8081/nexus/content/groups/hotent/%3C/url)

         &lt;/mirror&gt;

3.        增加外网的库下载地址（可建在内网）

&lt;repository&gt;  

           &lt;id&gt;sonatype&lt;/id&gt;  

           &lt;name&gt;sonatype&lt;/name&gt;

           &lt;url&gt;[http://repository.sonatype.org/content/groups/public/&lt;/url&gt;](http://repository.sonatype.org/content/groups/public/%3C/url)  

        &lt;/repository&gt;

       &lt;repository&gt;  

           &lt;id&gt;hotent-remote&lt;/id&gt;

            &lt;name&gt;remotehotent maven release&lt;/name&gt;  

           &lt;url&gt;[http://office.jee-soft.cn:8081/n ... hotent/&lt;/url&gt;](http://office.jee-soft.cn:8081/nexus/content/groups/hotent/%3C/url)  

        &lt;/repository&gt;

4.        设置自己有效的maven库

&lt;activeProfile&gt;hotent-remote&lt;/activeProfile&gt;

**设置命令环境下的maven**

我们有时希望是在命令窗口下直接使用Maven，执行mvn package等，这时需要设置好maven的命令环境。

1.      设置环境变量，如下所示：

  ![](http://dl2.iteye.com/upload/attachment/0096/5413/e5aca183-48f2-30d1-a59f-e910dbc63381.png)  
![](http://dl2.iteye.com/upload/attachment/0096/5415/e557dd17-55d5-35ca-9001-714c46b47602.png)![](http://dl2.iteye.com/upload/attachment/0096/5417/086f038f-53e3-3d8d-8b1e-6a063735fc61.png)  
   ![](http://dl2.iteye.com/upload/attachment/0096/5419/c122dd2d-118f-3533-859b-5162ea3c2002.png)  
同时在PATH变量中增加;%MVN\_HOME%\\bin;  
2.在命令环境下测试 mvn –version，显示以下则表示正确：  
  ![](http://dl2.iteye.com/upload/attachment/0096/5421/94a9fbf9-d059-39e5-be46-9c57aaca4274.png)  
**二、Maven与Eclipse开发工具整合**  
**Eclipse下载**

版本：Eclipse JavaEE IDE for Web Developers Version: Kepler Service Release 2

[https://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/keplersr2](https://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/keplersr2)

**m2e插件安装**

         以上eclipse版本已经默认带有m2e的插件，若是其他eclipse版本，请更新以下updatesite来安装m2e

http://download.eclipse.org/technology/m2e/releases

**m2e设置**

从eclipse环境进入参数设置环境（菜单Window—》Preferences）

 

1.      增加我们安装的maven目录

  ![](http://dl2.iteye.com/upload/attachment/0096/5423/d15f3e83-2b3f-3172-abb5-4fb4dad704ce.png)

 

2.      设置User Settings

  ![](http://dl2.iteye.com/upload/attachment/0096/5425/fa247ef7-59c2-3665-abe3-92e6f1de6cc2.png)

 

3.      设置与Maven库服务器进行索引同步

  ![](http://dl2.iteye.com/upload/attachment/0096/5427/41056c46-1cd1-34d8-a54f-b619397b8539.png)

 

4.      重启Eclipse，并且看到更新索引库，以下所示：

  ![](http://dl2.iteye.com/upload/attachment/0096/5429/8facaa9f-cdff-3133-8f38-6830ac306fd4.png)

 

这会导致每次启动时更新索引库，会有一定的耗时，可采用手工更新本地的索引库，进入以上的User Settings设置界面，点【Reindex】按钮。

**三、测试开发环境的maven**  
新建maven项目  
  ![](http://dl2.iteye.com/upload/attachment/0096/5431/ad88ddc0-09b1-3587-a6c1-e0a965439720.png)  
 

点【finish】按钮完成maven项目的创建。  
![](http://dl2.iteye.com/upload/attachment/0096/5433/9f46b863-fa97-3ffc-a8a1-1602847f1b9a.png)

**加入项目的依赖包**

双击该项目下的pom.xml文件，打开pom编辑器，并进入Dependencies面板，如下所示：

  ![](http://dl2.iteye.com/upload/attachment/0096/5435/4ef8acb1-7b18-333d-bf31-bb87bb120c33.png)

 

点击左边的【Add..】按钮，弹出选择

  ![](http://dl2.iteye.com/upload/attachment/0096/5437/f7fbee02-454c-3a07-b255-22bfe13629e8.png)

可以在选择结果下选择其中需要引入的依赖包

来自连接：

[http://www.activiti.org.cn/forum.php?mod=viewthread&tid=23](http://www.activiti.org.cn/forum.php?mod=viewthread&tid=23)