|
1 | | -<h1 id="maven0">Maven 安装和配置</h1> |
| 1 | +# Maven 安装和配置 |
2 | 2 |
|
3 | | ------- |
4 | 3 |
|
5 | | -* [Maven 安装和配置](#maven0) |
6 | | - * [Maven 安装](#maven1) |
7 | | - * [Maven 配置](#maven2) |
8 | | - * [资料](#maven3) |
9 | | - |
10 | | ------- |
11 | 4 |
|
12 | | -<h2 id="maven1">Maven 安装</h2> |
| 5 | +## Maven 安装 |
13 | 6 |
|
14 | 7 | - Maven 安装 |
15 | 8 | - 官网:<http://maven.apache.org/> |
|
25 | 18 | - 移到我个人习惯的安装目录下:`mv maven3.3.9/ /usr/program` |
26 | 19 | - 环境变量设置:`vim /etc/profile` |
27 | 20 | - 在文件最尾巴添加下面内容: |
| 21 | + |
28 | 22 | ``` |
29 | 23 | # Maven |
30 | 24 | MAVEN_HOME=/usr/program/maven3.3.9 |
|
34 | 28 | export PATH |
35 | 29 | export MAVEN_OPTS |
36 | 30 | ``` |
| 31 | +
|
37 | 32 | - 刷新配置文件:`source /etc/profile` |
38 | 33 | - 测试是否安装成功:`mvn -version` |
39 | 34 |
|
40 | 35 |
|
41 | | -<h2 id="maven2">Maven 配置</h2> |
| 36 | +## Maven 配置 |
| 37 | +
|
| 38 | +- 配置项目连接上私服 |
| 39 | +- 全局方式配置: |
| 40 | +
|
| 41 | +``` bash |
| 42 | +<?xml version="1.0" encoding="UTF-8"?> |
| 43 | +
|
| 44 | +<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"> |
| 45 | +
|
| 46 | + <!--本地仓库位置--> |
| 47 | + <localRepository>D:/maven/my_local_repository</localRepository> |
| 48 | +
|
| 49 | + <pluginGroups> |
| 50 | + </pluginGroups> |
| 51 | +
|
| 52 | + <proxies> |
| 53 | + </proxies> |
| 54 | +
|
| 55 | + <!--设置 Nexus 认证信息--> |
| 56 | + <servers> |
| 57 | + <server> |
| 58 | + <id>nexus-releases</id> |
| 59 | + <username>admin</username> |
| 60 | + <password>admin123</password> |
| 61 | + </server> |
| 62 | + <server> |
| 63 | + <id>nexus-snapshots</id> |
| 64 | + <username>admin</username> |
| 65 | + <password>admin123</password> |
| 66 | + </server> |
| 67 | + </servers> |
| 68 | +
|
| 69 | + <!--设置 Nexus 镜像,后面只要本地没对应的以来,则到 Nexus 去找--> |
| 70 | + <mirrors> |
| 71 | + <mirror> |
| 72 | + <id>nexus-releases</id> |
| 73 | + <mirrorOf>*</mirrorOf> |
| 74 | + <url>http://localhost:8081/nexus/content/groups/public</url> |
| 75 | + </mirror> |
| 76 | + <mirror> |
| 77 | + <id>nexus-snapshots</id> |
| 78 | + <mirrorOf>*</mirrorOf> |
| 79 | + <url>http://localhost:8081/nexus/content/groups/public-snapshots</url> |
| 80 | + </mirror> |
| 81 | + </mirrors> |
| 82 | +
|
| 83 | +
|
| 84 | + <profiles> |
| 85 | + <profile> |
| 86 | + <id>nexus</id> |
| 87 | + <repositories> |
| 88 | + <repository> |
| 89 | + <id>nexus-releases</id> |
| 90 | + <url>http://nexus-releases</url> |
| 91 | + <releases> |
| 92 | + <enabled>true</enabled> |
| 93 | + </releases> |
| 94 | + <snapshots> |
| 95 | + <enabled>true</enabled> |
| 96 | + </snapshots> |
| 97 | + </repository> |
| 98 | + <repository> |
| 99 | + <id>nexus-snapshots</id> |
| 100 | + <url>http://nexus-snapshots</url> |
| 101 | + <releases> |
| 102 | + <enabled>true</enabled> |
| 103 | + </releases> |
| 104 | + <snapshots> |
| 105 | + <enabled>true</enabled> |
| 106 | + </snapshots> |
| 107 | + </repository> |
| 108 | + </repositories> |
| 109 | + <pluginRepositories> |
| 110 | + <pluginRepository> |
| 111 | + <id>nexus-releases</id> |
| 112 | + <url>http://nexus-releases</url> |
| 113 | + <releases> |
| 114 | + <enabled>true</enabled> |
| 115 | + </releases> |
| 116 | + <snapshots> |
| 117 | + <enabled>true</enabled> |
| 118 | + </snapshots> |
| 119 | + </pluginRepository> |
| 120 | + <pluginRepository> |
| 121 | + <id>nexus-snapshots</id> |
| 122 | + <url>http://nexus-snapshots</url> |
| 123 | + <releases> |
| 124 | + <enabled>true</enabled> |
| 125 | + </releases> |
| 126 | + <snapshots> |
| 127 | + <enabled>true</enabled> |
| 128 | + </snapshots> |
| 129 | + </pluginRepository> |
| 130 | + </pluginRepositories> |
| 131 | + </profile> |
| 132 | + </profiles> |
| 133 | +
|
| 134 | + <activeProfiles> |
| 135 | + <activeProfile>nexus</activeProfile> |
| 136 | + </activeProfiles> |
| 137 | +
|
| 138 | +</settings> |
| 139 | +``` |
| 140 | + |
| 141 | +- 项目级别: |
| 142 | + |
| 143 | + |
42 | 144 |
|
43 | 145 |
|
44 | | -<h2 id="maven3">资料</h2> |
| 146 | +## 资料 |
45 | 147 |
|
46 | 148 | - <http://maven.apache.org/install.html> |
47 | 149 | - <http://www.tutorialspoint.com/maven/index.htm> |
48 | 150 | - <http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html> |
49 | 151 | - <http://maven.apache.org/guides/getting-started/index.html> |
50 | 152 | - <http://maven.apache.org/general.html> |
| 153 | +- <http://stackoverflow.com/questions/6950346/infrastructure-with-maven-jenkins-nexus> |
| 154 | +- <http://blog.csdn.net/sxyx2008/article/details/7975129> |
| 155 | +- <http://blog.csdn.net/xuke6677/article/details/8482472> |
0 commit comments